<p>I think that's just the way they have set up the templates in the example, so what you're doing is just fine (using <code>{% block %}</code>), if that's how your templates are set up. </p>

<p>The difference is by using <code>{% set %}</code> you are just setting your content to a variable which would be <code>{{ echoed }}</code> into the layout file that you extend. Whereas using <code>{% block %}</code> you are telling twig what block of content should be inherited into the layout you are extending.</p>

<p>The twig docs probably explain it better:</p>

<p><a href="http://twig.sensiolabs.org/doc/tags/extends.html">http://twig.sensiolabs.org/doc/tags/extends.html</a><br>
<a href="http://twig.sensiolabs.org/doc/tags/set.html">http://twig.sensiolabs.org/doc/tags/set.html</a></p>

<p>From the looks of it with the plugin in question, providing you add <code>{{ craft.sproutSeo.optimize() }}</code> into your layout template you should be all good to go. </p>

<h3>Example with <code>{% set %}</code></h3>

<p><strong>_layout.html</strong></p>

<pre><code>&lt;body&gt;
  {{ content }}
&lt;/body&gt;
</code></pre>

<p><strong>index.html</strong></p>

<pre><code>{% extends '_layout' %}

{% set content %}
 Some content
{% endset %}
</code></pre>

<h3>Example with <code>{% block %}</code></h3>

<p><strong>_layout.html</strong></p>

<pre><code>&lt;body&gt;
  {% block content %}{% endblock %}
&lt;/body&gt;
</code></pre>

<p><strong>index.html</strong></p>

<pre><code>{% extends '_layout' %}

{% block content %}
 Some content
{% endblock %}
</code></pre>

CC BY-SA 3.0
2015-05-27T21:17:40.360Z
thanks. Ill think in my case block will just be fine indeed.
imnotsure
CC BY-SA 3.0
2015-05-27T20:24:32.427Z
2015-05-27T20:24:32.427Z
Alec Ritson
<p>I usually use <code>{% block %}{% endblock %}</code> to build my template but for the <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/seo/docs/examples/extending-a-base-layout" rel="nofollow">SEO plugin</a> I'll be needing <code>{% set %}{% endset %}</code>. However my pages don't seem to render. If I change it to <code>{% block %}{% endblock %}</code> it works fine. </p>

<p>Anyone know what is causing this?</p>

<p>This is my base file _master.html (partly):</p>

<pre><code>&lt;body class="boxed bg-cover" style="background-image: url(img/backgrounds/street.jpg)"&gt;
 &lt;div class="global-wrap"&gt;
     {% set header %}
     {% endset %}
</code></pre>

<p>this is my index.html (partly):</p>

<pre><code>{% extends "_master" %}
 {% set header %}
   {% include 'header.html' %}
 {% endset %} 
</code></pre>

CC BY-SA 3.0
2015-05-27T20:13:19.460Z
can you show your code?
Steven Grant
CC BY-SA 3.0
2015-05-27T20:23:05.380Z
I edited the post. Its pretty straightforward.
imnotsure
CC BY-SA 3.0
2015-05-27T20:25:01.367Z
You'll need to print the header variable after setting, ie {{ header }}
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2015-05-27T21:08:53.233Z
Are you sure that the SEO plugin isn't working when you use `block`? That's largely a formatting preference... Templates render from the inside-out, so your `do` would still get called before anything in the master template.
Lindsey D
CC BY-SA 3.0
2015-05-27T21:15:24.923Z
I got a bit thrown off by this --> Note: In our examples we have chosen to use the {% set %} tag to build our layouts because it gets processed in the same way as all of the other Twig tags - from top to bottom. The {% block %} tag, while useful for many use cases in your templates, does not get processed until last, so we’re unable to update our meta data using craft.sproutSeo.meta() in a {% block %} tag because our craft.sproutSeo.optimize() tag gets processed before the {% block %} tag runs.
imnotsure
CC BY-SA 3.0
2015-05-27T21:20:27.777Z
Ah, interesting. I didn't catch that!
Lindsey D
<templating><plugin-sproutseo>
Problem using "set" with Sprout SEO
# Problem using "set" with Sprout SEO

(Asked by: username_0 on 2015-05-27)

I usually use {% block %}{% endblock %} to build my template but for the SEO plugin I'll be needing {% set %}{% endset %}. However my pages don't seem to render. If I change it to {% block %}{% endblock %} it works fine. 
Anyone know what is causing this?
This is my base file _master.html (partly):

 
     {% set header %}
     {% endset %}

this is my index.html (partly):
{% extends "_master" %}
 {% set header %}
   {% include 'header.html' %}
 {% endset %}

**Tags:** templating, plugin-sproutseo

> **Comments:**
> **username_1**: can you show your code?  
> **username_0**: I edited the post. Its pretty straightforward.  
> **username_2**: You'll need to print the header variable after setting, ie {{ header }}  
> **username_3**: Are you sure that the SEO plugin isn't working when you use `block`? That's largely a formatting preference... Templates render from the inside-out, so your `do` would still get called before anything in the master template.  
> **username_0**: I got a bit thrown off by this --> Note: In our examples we have chosen to use the {% set %} tag to build our layouts because it gets processed in the same way as all of the other Twig tags - from top to bottom. The {% block %} tag, while useful for many use cases in your templates, does not get processed until last, so we’re unable to update our meta data using craft.sproutSeo.meta() in a {% block %} tag because our craft.sproutSeo.optimize() tag gets processed before the {% block %} tag runs.  
> **username_3**: Ah, interesting. I didn't catch that!  

---

## 1 answers

### Answer by username_4 on 2015-05-27. Score: 5 | Accepted answer

I think that's just the way they have set up the templates in the example, so what you're doing is just fine (using {% block %}), if that's how your templates are set up. 
The difference is by using {% set %} you are just setting your content to a variable which would be {{ echoed }} into the layout file that you extend. Whereas using {% block %} you are telling twig what block of content should be inherited into the layout you are extending.
The twig docs probably explain it better:
http://twig.sensiolabs.org/doc/tags/extends.html
http://twig.sensiolabs.org/doc/tags/set.html
From the looks of it with the plugin in question, providing you add {{ craft.sproutSeo.optimize() }} into your layout template you should be all good to go. 
Example with {% set %}
_layout.html

  {{ content }}


index.html
{% extends '_layout' %}

{% set content %}
 Some content
{% endset %}

Example with {% block %}
_layout.html

  {% block content %}{% endblock %}


index.html
{% extends '_layout' %}

{% block content %}
 Some content
{% endblock %}

> **Comments:**
> **username_0**: thanks. Ill think in my case block will just be fine indeed.  

---

