Reputation: 241
How do I hide a page in Jekyll? I have a Contact Us page (as a Google Docs form), and there is a response page. When created, it shows up in the navigation as a child of the Contact Us page, but I don't want it to show up at all.
I currently have this set up in the front matter like this:
---
layout: page
title: Thanks
permalink: /contact/thanks/
---
Upvotes: 24
Views: 7861
Reputation: 180
Rather than 'opting out' of including certain pages, you can 'opt in' to include only the pages you do want included in your navigation. This is useful if you have a large number of pages.
Include a menu
variable in the front matter of every page you do want included in the navigation:
---
layout: blog
title: Blog
menu: main
permalink: /blog/
---
And then add an if statement where your navigation is generated:
<ul>
{% for page in site.pages %}
{% if page.menu == 'main' %}
<li><a href="{{ page.url | prepend: site.baseurl }}">{{ page.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
This is likely to be in _layouts/default.html
or possibly _includes/header.html
.
Thanks to David Jaquel's answer on this question for the inspiration: Excluding page from Jekyll navigation bar
Upvotes: 15
Reputation: 15545
According to docs, set published to false in your front matter:
---
layout: post
title: Blogging Like a Hacker
published: false
---
Upvotes: 6
Reputation: 372
If you do not put any title in the page, it does not show up in the nav bar. Something like
---
layout: page
permalink: /contact/thanks/
---
Upvotes: 22
Reputation: 52789
Just add a show_in_nav: false
in you page front matter and in your navigation bar, do a :
<ul>
{% for p in pages %}
{% unless show_in_nav == false %}
<li><a href="{{ site.baseurl }}{{ p.url }}">{{ p.title }}</a></li>
{% endunless %}
{% endfor %}
</ul>
This will prevent your page from appearing in navigation bar.
Upvotes: 5