goal
Generate a page list filtered by a single tag.
problem
List doesn't appear.
things I tried
I started with the <nav>
element in the default Jekyll site:
<nav class="site-nav">
<div class="trigger">
{% for page in site.pages %}
{% if page.title %}
<a class="page-link" href="{{ page.url | prepend: site.baseurl }}">{{ page.title }}</a>
{% endif %}
{% endfor %}
</div>
</nav>
When the Jekyll site is serve
d, this puts an "About" page in the nav
element.
I added two tags to different pages' front matter on the site:
tags:
- eng
---
I tried both formats:
tags: eng
---
Try enumerating through
site.tags.eng
(also triedsite.tags[eng]
andsite.tags["eng"]
):<div class="trigger"> {% for page in site.tags.eng %} {% if page.title %} <a class="page-link" href="{{ page.url | prepend: site.baseurl }}">{{ page.title }}</a> {% endif %} {% endfor %} </div>
Try testing for a tag (with or without quotes):
<div class="trigger"> {% for tag in site.tags %} {% if tag == "eng" %} {% if page.title %} <a class="page-link" href="{{ page.url | prepend: site.baseurl }}">{{ page.title }}</a> {% endif %} {% endif %} {% endfor %} </div>
Also add a tag list to
_config.yml
:# Tags tags: [eng, jpn]
Add a tag to the sample post to see if only posts are being indexed
other questions I looked at
- Generating a list of pages (not posts) in a given category: not sure how what I'm trying is fundamentally different
- http://jekyllrb.com/docs/variables/: the Jekyll main documentation doesn't say that tags have to be specified in the config YAML
- https://stackoverflow.com/questions/18944264/jekyll-plugin-liquid-tag-creation-not-working: It doesn't seem like I should have to build a whole plugin for this.