Answers.Body: <p>Another way to approach this would be to standardize the different elements by passing them to a common included template with the same variable</p>
  
  <p>For entry pages:</p>
  
  <pre><code>{% if entry is defined %}
      {% include '_partials/meta' with {
          element: entry
      } %}
  {% endif %}
  </code></pre>
  
  <p>For category pages:</p>
  
  <pre><code>{% if category is defined %}
    {% include '_partials/meta' with {
          element: category
      } %}
  {% endif %}
  </code></pre>
  
  <p>Now you can use the common <code>element</code> 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:</p>
  
  <pre><code>{# _partials/meta #}
  
  &lt;title&gt;{{ element.title }}&lt;/title&gt;
  &lt;meta name="description" content="{{ element.description }}"&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-08T16:58:28.750Z
Answers.LastActivityDate: 2016-09-08T16:58:28.750Z
Answers.UserDisplayName: Ben Parizek
Answers.Body: <p>You have to type out the complete statement for each condition, i.e. </p>
  
  <pre><code>{% if entry is defined or category is defined %}
      ...
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-08T09:24:31.443Z
Answers.LastActivityDate: 2016-09-08T09:24:31.443Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I'm trying to do something like this for all the SEO meta info in my head</p>
  
  <pre><code>{% if entry or category is defined %}
   ...
  {% endif %}
  </code></pre>
  
  <p>What's the right way to code this?</p>
  
  <p>The reason for this is I have archive pages which won't be using some the meta information.</p>
  
Tags: <conditional>
Title: Conditions in an if statement 'or'
ThreadText: # Conditions in an if statement 'or'
  
  (Asked by: username_0 on 2016-09-08)
  
  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.
  
  **Tags:** conditional
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-09-08. Score: 5 | Accepted answer
  
  You have to type out the complete statement for each condition, i.e.
  
  ```
  {% if entry is defined or category is defined %}
      ...
  {% endif %}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2016-09-08. Score: 4
  
  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 }}">
  
  ```
  
  
  ---
  
  