Skip to content

Instantly share code, notes, and snippets.

@sskylar
Last active August 29, 2015 14:16
Show Gist options
  • Save sskylar/33eba32f124634e92368 to your computer and use it in GitHub Desktop.
Save sskylar/33eba32f124634e92368 to your computer and use it in GitHub Desktop.
Long page in Siteleaf with multiple content sections and sub-sections
<h1>{{title}}</h1>
{{body}}
{% for section in pages %}
<h2 id="{{section.slug}}">{{section.title}}</h2>
{{section.body}}
{% for subsection in section.pages %}
<h3 id="{{subsection.slug}}">{{subsection.title}}</h3>
{{subsection.body}}
{% endfor %}
{% endfor %}
@sskylar
Copy link
Author

sskylar commented Mar 12, 2015

To use this, break your sub/sections into individual pages:

This makes it easy to drag and reorder your content, plus each sub/section gets its own set of metadata and assets to use.

Using id="{{section.slug}}" also allows you to use anchor links (e.g. #your-slug) to help with navigation.

If you would like to have sub/sections non-accessible by permalink, you can also add the following code to redirect /parent/section to /parent/#section:

<!doctype html>
<html>
  <head>
    <meta http-equiv="refresh" content="0;url=/{{ parent.url }}/#{{ slug }}">
  </head>
  <body>
  </body>
</html>

@johnchourajr
Copy link

Is there any way to call a specific section name? Calling sections around markup for a specific section loops that section as many times as a section appears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment