How to render content in different blocks

I understand that everything inside the pages folder is being rendered in the content block.
But I also have different types of content that I would like to render in another block.

For instance: I am using the foundation framework and generally all content is rendered within a div with a row class which defines the pages boundaries. But on my homepage I want to place an image slider which uses the full browser’s width.

{% block before_content %},{% endblock %}
<div class="row">
   <div class="large-12 columns">
      {% block content %},{% endblock %}

How can I tell my slider’s content it should render in ‘before_content’ instead of ‘content’?

Sounds like you might want to look at modular page types for your homepage. That way you can build a page with multiple markdown files for different areas of your homepage, each with their own twig file to render. Check out the One-Page Skeleton in the downloads for a good working example of how this is achieved.

Thanks. I ended up doing that.

Still having a problem to wrap my head around. I can’t get over it that there SEEMS to be only the {{ page.content }} variable where everything from the folder ‘pages’ goes. Am I right about that?

I managed to solve my original issue with a modular page but now I am facing a new one. In my footer, which is global, I want to place an additional section which should be fillable by markdown like all the other content in the ‘pages’ folder.

I don’t want to hardcode content in a twig template. Template and content should stay separate. So how can I render content for the footer that is NOT part of {{ page.content }}?

stick your code into a footer partial. Have a look at the Bones Skeleton , they have a good example how this can be achieved.


{% block footer %}
        {% set content = pages.find('/footer').content %}
        {% if content %}
        <footer id="footer">
            <div class="row sg-center">
                 {{ content }}
        {% endif %}
{% endblock %}

The magic is to pull the content into a variable first. Seems a little clumsy but will do the trick. This is the official way?

Yup, that’s perfectly legit! Might wan to use another variable so it doesn’t conflict with the content that is set in Twig vars, but other than that it’s good.

Thanks! That’s what i needed. I slightly changed the code to have the if statement test the “Page” instead of the content, makes more sense to me to do it this way.

{% set footerpage = pages.find('/footer') %}
{% if footerpage %}
   {{ footerpage.content }}
{% endif %}