siteleaf / siteleaf-v1-themes

Siteleaf v1 theme documentation
http://www.siteleaf.com
69 stars 7 forks source link

Using if statement with slugs to define includes not working #3

Closed kilmc closed 10 years ago

kilmc commented 10 years ago

Hey guys,

I'm pretty sure this is just me doing something wrong but I wanted to check. I'm trying to clean up my code and I'm moving away from multiple index files.

I now have one index.html in the root directory and in it I've added this block

{% if slug == 'teaser' %}
{% include 'includes/teaser' %}
{% elsif slug == 'blog' %}
{% include 'includes/blog' %}
{% endif %}

Both those includes are at those paths.

Also when I duplicate the root index.html and put it in a /blog directory it renders the page correctly.

Thanks in advance

destroytoday commented 10 years ago

index.html only represents one page, so if you want a template to cover an entire directory tree, you need to rename it to default.html. Also, if blog is your home page (at the top of the pages list), the slug will return blank.

kilmc commented 10 years ago

Brilliant. I knew it had to be me doing something simple incorrectly. Got it all working now. Thanks.