I'm currently trying to make my navigation be not included on my index page due to my loading a different style of page - but - include it on every other page. My current layout looks like so:


{% set exclusions = ['index'] %}
{% if craft.request.firstSegment not in exclusions  %}
    {% include '_navigation' %}
{% endif %}

But this seems to not work on my "index.html" page. Do I need to set it a title? or set an exclusion name here?

  • Is the first segment blank by chance? If so you can check if it’s empty. Feb 25 '18 at 16:51
  • I'm not sure, I'm just trying to exclude this template when on the index page
    – JMKelley
    Feb 25 '18 at 17:10
  • This will only work if your first url segment is 'index' so when your url is www.example.com/index it won't work for www.example.com. Do you have different templates for you first page and for the rest of them? Feb 25 '18 at 18:39
  • @RobinSchambach I have a _layout.html include on the index page and within layout is navigation.html
    – JMKelley
    Feb 25 '18 at 20:36
  • This doesn't answer my question. Do you use the template you use for your index page for any other page? Feb 25 '18 at 20:39

You can check against the Entry Type as well. I would try to validate it with something like:

{% set exclusions = ['home'] %}    
{% if entry.type not in exclusions %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.