Answers.Body: <p>Sprout SEO 3 allows this same functionality but takes a different approach.</p>
  
  <p>With Sprout SEO 3, in most cases, you can replace all of the template code that was required in Sprout SEO 2 with the single tag: <code>{% sproutseo 'optimize' %}</code> and the new <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/core-concepts/element-metadata-field" rel="nofollow noreferrer">Element Metadata</a> field.</p>
  
  <p>The Element Metadata field allows you to map the fields you wish to have as fallbacks. So, where you previously may have done this in Sprout SEO 2:</p>
  
  <pre><code>{% do craft.sproutSeo.meta({
      id: entry.id,
      title: entry.title,
      description: entry.body|striptags|slice(0, 160)
  }) %}
  </code></pre>
  
  <p>You can now just set up an Element Metadata field and map the Title to the Entry Title and so on. The Element Metadata field supports one to one mappings or Custom Patterns where you can use twig code to define the metadata you wish to map.</p>
  
  <p>If you wish to get more specific with the Element Metadata and have both the ability to do a fallback mapping and allow the user to override the metadata values, you can enable the <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/advanced-customization/meta-details-fields" rel="nofollow noreferrer">Meta Details Fields</a> in the Advanced settings area.</p>
  
  <p>You may need to setup more than one Element Metadata field if you have more than one type of mapping you wish to do across various sections of your site.</p>
  
  <p>The <code>entry.id</code> variable no longer needs to get used in your template in Sprout SEO 3. Sprout SEO 3 now identifies the entry that is being loaded on the page dynamically, just as Craft knows what <code>entry</code> variable to make available to the page.</p>
  
  <p>I believe the above should address the fallback issue you describe and is the recommended approach to preparing your fallbacks in the most manageable and maintainable way. I've yet to have someone give me a scenario that doesn't fit in the above model, but if you feel like you have one, feel free to reach out to us via support and I'd be happy to chat it through.</p>
  
  <hr>
  
  <p>To address your final comment:</p>
  
  <blockquote>
    <p>Although this requires disabling automatic metadata rendering, which I
    require elsewhere, and enabling the custom metadata variable. It also
    omits the fallback SEO metadata as this now overrides the entry's
    metadata.</p>
  </blockquote>
  
  <p>If it's really necessary to override the default metadata, Sprout SEO gives you control over two things:</p>
  
  <ol>
  <li>To make the prioritized metadata available to the page as a variable</li>
  <li>To disable the default rendering of the metadata</li>
  </ol>
  
  <p>These two settings should give you control over a scenario where you want to both control how some metadata is output on your own and output some metadata in the same way that we do. For more advanced use cases, you just get to manage how the logic works around that on your own. </p>
  
  <p>A very general example of how this could be done would be by making the <code>metadata</code> variable available to the page and copying over the default Sprout SEO metadata.html and wrapping a conditional around it. Something like:</p>
  
  <pre><code>{% if somethingIsTrue %}
      {# Do something special #}
  {% else %}
      {# Output the default metadata template found in:
         sproutseo/templates/_special/metadata.html #}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-20T10:41:47.557Z
Answers.Text: Thanks for the comprehensive answer. I have decided not to implement fallback metadata in order to simplify things. Regarding the use of `entry.id`, I probably wasn't explicit enough in stating that I was iterating over a list of entries, each of which I needed the metadata for. I've ended up using expressions such as `{{ entry.sproutSeoElementMetadata.title }}` for this.
Answers.UserDisplayName: Mark Hobson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-21T22:14:59.480Z
Answers.Text: Thanks for the clarification, Mark. We do have on our list to make it easier to output metadata for each Element in a loop. If you wish to talk things through further, feel free to reach out to us via support. We appreciate understanding these unique use cases as well as we can to make sure we're considering them as we continue development on the plugin.
Answers.UserDisplayName: Ben Parizek
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-18T05:29:52.277Z
Answers.LastActivityDate: 2017-04-18T05:29:52.277Z
Answers.UserDisplayName: Ben Parizek
Answers.Body: <p>I didn't understand Ben's answer, and I just needed to output an entry's SEO meta title with a fallback to the entry title in a <code>for</code> loop. Maybe this will help someone in a similar situation:</p>
  
  <pre><code>{% for entry in entries %}
      {% if entry.sproutSeoElementMetadata.title %}
          {% set title = entry.sproutSeoElementMetadata.title %}
      {% else %}
          {% set title = entry.title %}
      {% endif %}
      &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <hr>
  
  <p>Just like <code>entry.sproutSeoElementMetadata.title</code> will grab the meta title of that entry, you can do the same with description: <code>entry.sproutSeoElementMetadata.description</code></p>
  
  <p>The meta image is a bit more complicated though:</p>
  
  <pre><code>{# get meta image's asset id #}
  {% set imageId = entry.sproutSeoElementMetadata.ogImage %}
  
  {# get the actual asset image by its id #}
  {% set image = craft.assets.id(imageId).first %}
  
  {# output the image's url #}
  {{ image.url }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-13T21:51:22.003Z
Answers.LastActivityDate: 2017-09-15T21:00:38.717Z
Answers.LastEditDate: 2017-09-15T21:00:38.717Z
Answers.UserDisplayName: Ryan
Body: <p>Under Sprout SEO 2 I am able to obtain the SEO metadata for a specific <code>entry</code> as follows:</p>
  
  <pre><code>{% do craft.sproutSeo.meta({
      id: entry.id,
      title: entry.title,
      description: entry.body|striptags|slice(0, 160)
  }) %}
  {{ craft.sproutSeo.getOptimizedMeta().basic.title }}
  {{ craft.sproutSeo.getOptimizedMeta().basic.description }}
  </code></pre>
  
  <p>Here I am using the entry's <code>title</code> and <code>body</code> fields as fallback SEO metadata if none is specified on the entry. This is all <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/sprout-seo-2/introduction#managing-your-seo-metadata-in-your-template" rel="nofollow noreferrer">documented for Sprout SEO 2</a>.</p>
  
  <p>How do I achieve this under Sprout SEO 3? The closest I can get is as follows:</p>
  
  <pre><code>{% do craft.sproutSeo.meta({
      id: entry.id
  }) %}
  {% sproutseo 'optimize' %}
  {{ metadata.meta.search.title }}
  {{ metadata.meta.search.description }}
  </code></pre>
  
  <p>Although this requires <a href="https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/advanced-customization/custom-metadata-variable" rel="nofollow noreferrer">disabling automatic metadata rendering</a>, which I require elsewhere, and enabling the custom <code>metadata</code> variable. It also omits the fallback SEO metadata as this now overrides the entry's metadata.</p>
  
Tags: <plugin-sproutseo>
Title: Obtaining SEO metadata for a specific entry under Sprout SEO 3
ThreadText: # Obtaining SEO metadata for a specific entry under Sprout SEO 3
  
  (Asked by: username_0 on 2017-04-13)
  
  Under Sprout SEO 2 I am able to obtain the SEO metadata for a specific `entry` as follows:
  
  ```
  {% do craft.sproutSeo.meta({
      id: entry.id,
      title: entry.title,
      description: entry.body|striptags|slice(0, 160)
  }) %}
  {{ craft.sproutSeo.getOptimizedMeta().basic.title }}
  {{ craft.sproutSeo.getOptimizedMeta().basic.description }}
  
  ```
  
  Here I am using the entry's `title` and `body` fields as fallback SEO metadata if none is specified on the entry. This is all [documented for Sprout SEO 2](https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/sprout-seo-2/introduction#managing-your-seo-metadata-in-your-template).
  
  How do I achieve this under Sprout SEO 3? The closest I can get is as follows:
  
  ```
  {% do craft.sproutSeo.meta({
      id: entry.id
  }) %}
  {% sproutseo 'optimize' %}
  {{ metadata.meta.search.title }}
  {{ metadata.meta.search.description }}
  
  ```
  
  Although this requires [disabling automatic metadata rendering](https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/advanced-customization/custom-metadata-variable), which I require elsewhere, and enabling the custom `metadata` variable. It also omits the fallback SEO metadata as this now overrides the entry's metadata.
  
  **Tags:** plugin-sproutseo
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-04-18. Score: 0 | Accepted answer
  
  Sprout SEO 3 allows this same functionality but takes a different approach.
  
  With Sprout SEO 3, in most cases, you can replace all of the template code that was required in Sprout SEO 2 with the single tag: `{% sproutseo 'optimize' %}` and the new [Element Metadata](https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/core-concepts/element-metadata-field) field.
  
  The Element Metadata field allows you to map the fields you wish to have as fallbacks. So, where you previously may have done this in Sprout SEO 2:
  
  ```
  {% do craft.sproutSeo.meta({
      id: entry.id,
      title: entry.title,
      description: entry.body|striptags|slice(0, 160)
  }) %}
  
  ```
  
  You can now just set up an Element Metadata field and map the Title to the Entry Title and so on. The Element Metadata field supports one to one mappings or Custom Patterns where you can use twig code to define the metadata you wish to map.
  
  If you wish to get more specific with the Element Metadata and have both the ability to do a fallback mapping and allow the user to override the metadata values, you can enable the [Meta Details Fields](https://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/advanced-customization/meta-details-fields) in the Advanced settings area.
  
  You may need to setup more than one Element Metadata field if you have more than one type of mapping you wish to do across various sections of your site.
  
  The `entry.id` variable no longer needs to get used in your template in Sprout SEO 3. Sprout SEO 3 now identifies the entry that is being loaded on the page dynamically, just as Craft knows what `entry` variable to make available to the page.
  
  I believe the above should address the fallback issue you describe and is the recommended approach to preparing your fallbacks in the most manageable and maintainable way. I've yet to have someone give me a scenario that doesn't fit in the above model, but if you feel like you have one, feel free to reach out to us via support and I'd be happy to chat it through.
  
  ---
  
  To address your final comment:
  
  > Although this requires disabling automatic metadata rendering, which I
  > require elsewhere, and enabling the custom metadata variable. It also
  > omits the fallback SEO metadata as this now overrides the entry's
  > metadata.
  
  If it's really necessary to override the default metadata, Sprout SEO gives you control over two things:
  
  1. To make the prioritized metadata available to the page as a variable
  2. To disable the default rendering of the metadata
  
  These two settings should give you control over a scenario where you want to both control how some metadata is output on your own and output some metadata in the same way that we do. For more advanced use cases, you just get to manage how the logic works around that on your own.
  
  A very general example of how this could be done would be by making the `metadata` variable available to the page and copying over the default Sprout SEO metadata.html and wrapping a conditional around it. Something like:
  
  ```
  {% if somethingIsTrue %}
      {# Do something special #}
  {% else %}
      {# Output the default metadata template found in:
         sproutseo/templates/_special/metadata.html #}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the comprehensive answer. I have decided not to implement fallback metadata in order to simplify things. Regarding the use of `entry.id`, I probably wasn't explicit enough in stating that I was iterating over a list of entries, each of which I needed the metadata for. I've ended up using expressions such as `{{ entry.sproutSeoElementMetadata.title }}` for this.  
  > **username_1**: Thanks for the clarification, Mark. We do have on our list to make it easier to output metadata for each Element in a loop. If you wish to talk things through further, feel free to reach out to us via support. We appreciate understanding these unique use cases as well as we can to make sure we're considering them as we continue development on the plugin.  
  
  ---
  
  ### Answer by username_2 on 2017-09-13. Score: 1
  
  I didn't understand Ben's answer, and I just needed to output an entry's SEO meta title with a fallback to the entry title in a `for` loop. Maybe this will help someone in a similar situation:
  
  ```
  {% for entry in entries %}
      {% if entry.sproutSeoElementMetadata.title %}
          {% set title = entry.sproutSeoElementMetadata.title %}
      {% else %}
          {% set title = entry.title %}
      {% endif %}
      <li><a href="{{ entry.url }}">{{ title }}</a></li>
  {% endfor %}
  
  ```
  
  ---
  
  Just like `entry.sproutSeoElementMetadata.title` will grab the meta title of that entry, you can do the same with description: `entry.sproutSeoElementMetadata.description`
  
  The meta image is a bit more complicated though:
  
  ```
  {# get meta image's asset id #}
  {% set imageId = entry.sproutSeoElementMetadata.ogImage %}
  
  {# get the actual asset image by its id #}
  {% set image = craft.assets.id(imageId).first %}
  
  {# output the image's url #}
  {{ image.url }}
  
  ```
  
  
  ---
  
  