Closed notakoder closed 3 years ago
The if clause page.id starts with "folder/"
should already exclude all pages within folder/subfolder
:thinking:
Anyway, there are some ways to implement something like this:
hidden
YAML meta header (i.e. a exclude list approach). Add hidden: true
to all pages which shouldn't be listed there.nav
meta header (i.e. a include list approach). Simply add nav: true
to all pages which should appear in your nav bar and use a if clause like {{ if page.meta.nav }}
in your Twig template.content/page.md
and content/sub/index.md
, but not content/sub/page.md
) only. You can easily modify this to also include pages config.yml
(like nav_exclude: [ "folder/", "other_folder" ]
) and use a appropriate if clause in your Twig templates, e.g. {{ if page.id in config.nav_include }}
(include list) or {{ if page.id not in config.nav_exclude }}
(exclude list)Thanks...
I list my posts inside the folder 'folder' using the following snippet.
{% if (page.id starts with "folder/") and not (page.id starts with "folder/subfolder")and not page.hidden %}
I do not want posts from inside subfolder to appear, so I blacklisted it. The problem is that every time I create a subfolder, I'd have to blacklist it manually. Is there a way blacklist all the sub directories inside folder 'folder' instead of doing it manually?