Skip to content

Instantly share code, notes, and snippets.

@mikemartin
Last active January 6, 2022 19:27
Show Gist options
  • Select an option

  • Save mikemartin/6ec5edcb041792e873ff91a1e510a7d7 to your computer and use it in GitHub Desktop.

Select an option

Save mikemartin/6ec5edcb041792e873ff91a1e510a7d7 to your computer and use it in GitHub Desktop.

Revisions

  1. mikemartin revised this gist Jun 30, 2020. No changes.
  2. mikemartin revised this gist Jun 30, 2020. No changes.
  3. mikemartin created this gist Jun 30, 2020.
    42 changes: 42 additions & 0 deletions _seo.antlers.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    {{ if seo_title == 'custom' }}
    <title>{{ custom_title }}</title>
    <meta name="twitter:title" content="{{ custom_title }}" />
    <meta property="og:title" content="{{ custom_title }}" />
    {{ else }}
    <title>{{ title }} // {{ site:name }}</title>
    <meta name="twitter:title" content="{{ title }}" />
    <meta property="og:title" content="{{ title }}" />
    {{ /if }}

    {{ if seo_description == 'custom' }}
    <meta name="description" content="{{ custom_description }}">
    <meta name="twitter:description" content="{{ custom_description }}" />
    <meta property="og:description" content="{{ custom_description }}" />
    {{ elseif seo_description }}
    <meta name="description" content="{{ seo_description == 'subtitle' ?= subtitle }}">
    <meta name="twitter:description" content="{{ seo_description == 'subtitle' ?= subtitle }}" />
    <meta property="og:description" content="{{ seo_description == 'subtitle' ?= subtitle }}" />
    {{ elseif description }}
    <meta name="description" content="{{ description|striptags }}">
    <meta name="twitter:description" content="{{ description|striptags }}" />
    <meta property="og:description" content="{{ description|striptags }}" />
    {{ /if }}

    {{ if social_image == 'custom' }}
    {{ assets:custom_image }}
    <meta property="og:image" content="{{ site:url }}{{ glide:url w='1200' h='600' }}">
    <meta name="twitter:image" content="{{ site:url }}{{ glide:url w='1200' h='600' }}">
    {{ /assets:custom_image }}
    <meta name="twitter:card" content="summary_large_image" />
    {{ elseif image }}
    {{ assets:image }}
    <meta property="og:image" content="{{ site:url }}{{ glide:url w='1200' h='600' }}">
    <meta name="twitter:image" content="{{ site:url }}{{ glide:url w='1200' h='600' }}">
    {{ /assets:image }}
    <meta name="twitter:card" content="summary_large_image" />
    {{ /if }}

    <meta property="og:url" content="{{ site:url }}" />
    <meta property="og:type" content="article" />

    {{ yield:seo }}
    118 changes: 118 additions & 0 deletions seo.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,118 @@
    title: SEO Basic
    fields:
    -
    handle: section_title
    field:
    type: section
    instructions: 'Every URL in your site should have a unique SEO Title, ideally less than 60 characters long.'''
    localizable: false
    listable: hidden
    display: 'SEO Title'
    -
    handle: seo_title
    field:
    options:
    custom: Custom
    multiple: false
    searchable: false
    taggable: false
    push_tags: false
    cast_booleans: false
    type: select
    localizable: false
    listable: hidden
    display: 'Title'
    placeholder: 'Inherit Title'
    clearable: true
    width: 33
    -
    handle: custom_title
    field:
    input_type: text
    character_limit: 60
    type: text
    localizable: false
    listable: hidden
    display: 'Custom Title'
    if:
    seo_title: 'equals custom'
    width: 66
    -
    handle: section_description
    field:
    type: section
    instructions: 'Every URL in your site should have a unique SEO Description, ideally less than 160 characters long.'
    localizable: false
    listable: hidden
    display: 'SEO Description'
    -
    handle: seo_description
    field:
    options:
    subtitle: Subtitle
    custom: Custom
    multiple: false
    searchable: false
    taggable: false
    push_tags: false
    cast_booleans: false
    type: select
    localizable: false
    listable: hidden
    display: 'Description'
    clearable: true
    placeholder: 'Inherit Description'
    width: 33
    -
    handle: custom_description
    field:
    input_type: text
    character_limit: 160
    type: text
    localizable: false
    listable: hidden
    display: 'Custom Description'
    width: 66
    if:
    seo_description: 'equals custom'
    -
    handle: section_image
    field:
    type: section
    instructions: 'This image is used as a social network preview image.'
    localizable: false
    listable: hidden
    display: 'Social Image'
    -
    handle: social_image
    field:
    options:
    custom: Custom
    multiple: false
    searchable: false
    taggable: false
    push_tags: false
    cast_booleans: false
    type: select
    localizable: false
    listable: hidden
    clearable: true
    width: 33
    placeholder: 'Inherit Icon or Image'
    display: 'Image'
    -
    handle: custom_image
    field:
    container: assets
    mode: grid
    folder: seo
    restrict: false
    allow_uploads: true
    max_files: 1
    type: assets
    localizable: false
    listable: hidden
    width: 66
    display: 'Custom Image'
    if:
    social_image: 'equals custom'