Possible to automatically fill SEO page title and SEO canonical?

Correct, I don’t think those fields accept Liquid.

I approach this in a different way and handle the logic in the template.
I’m assuming you want to set these other SEO meta tags based on information already available from the page/item - to avoid double handling data? or to create some sort of dynamically generated value? but either way, I think the general process below can be applied/adapted.

So I do this for all the meta data tag and schema tags, but I’ll outline the process I have for the ‘title’ meta.
First I set up a hierarchy of which ‘title’ value takes priority:

{% capture pgOGelsSEOelsName %}
{% if this.OpenGraphProperties.title != null %}
    {{this.OpenGraphProperties.title | replace:' ', ' '}}
{% elsif this.SEOTitle != null %}
    {{this.SEOTitle | replace:' ', ' '}}
{% else %}
    {{this.name | replace:' ', ' '}}
{% endif %}
{% endcapture %}

So here, if the OG Title is present it takes priority, followed by the SEO/Meta Title if present, followed by the page name as a fallback/default.

and then, set up the meta tags:

{% if this.OpenGraphProperties.title == null %}
<meta property="og:title" content="{{pgOGelsSEOelsName | strip_html}}" />
{% endif %}
<meta name="twitter:title" content="{{pgOGelsSEOelsName | strip_html}}" />

Here I’ve added the Twitter schema for title - you can use the same value to add other schemas you might need to implement.

I find this process helps reduce data entry as most of the time all the meta data is the same and doesn’t need to be entered in all the fields.

Sorry if this is complete overkill for what you were actually asking :slight_smile: but hopefully it’s helpful.

I’ll be posting my full meta/schema data snippet on the Treehouse site soon, but I need to make a few tweaks first…

5 Likes