I'm trying to do something like this for all the SEO meta info in my head

{% if entry or category is defined %}
{% endif %}

What's the right way to code this?

The reason for this is I have archive pages which won't be using some the meta information.

2 Answers 2


You have to type out the complete statement for each condition, i.e.

{% if entry is defined or category is defined %}
{% endif %}

Another way to approach this would be to standardize the different elements by passing them to a common included template with the same variable

For entry pages:

{% if entry is defined %}
    {% include '_partials/meta' with {
        element: entry
    } %}
{% endif %}

For category pages:

{% if category is defined %}
  {% include '_partials/meta' with {
        element: category
    } %}
{% endif %}

Now you can use the common element variable to output any values. This would be easiest if you also used the same seo fields (title, description, etc.) on all of the different Elements you wanted to support SEO for:

{# _partials/meta #}

<title>{{ element.title }}</title>
<meta name="description" content="{{ element.description }}">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.