Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new section to Quick Tip #004—Zero Maintenance Tag Pages for your Blog #1646

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/docs/quicktips/tag-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ permalink: /tags/{{ tag }}/

Now Eleventy will only generate a `/tags/personal/` template and `tech` will be ignored.

## Include all Tag Pages in the `all` Collection

By default, only the first page generated with pagination will be added to the `all` collection. Ordinarily, this is not a problem, but with how we are using pagination in this unconventional manner to generate Tag Pages, you will likely want each Tag Page to be added to the `all` collection (very helpful to later generate a sitemap.xml file). Pages must opt-in to change this behavior by setting `addAllPagesToCollections` to `true` like this:

{% raw %}
```markdown
---
pagination:
addAllPagesToCollections: true
data: collections
size: 1
alias: tag
filter:
- tech
permalink: /tags/{{ tag }}/
---
```
{% endraw %}

## In Practice

This is currently in use on the [`eleventy-base-blog` sample project](https://github.com/11ty/eleventy-base-blog). Check out source code in the [`tags.njk` template](https://github.com/11ty/eleventy-base-blog/blob/main/content/tags.njk) and [see a live demo](https://eleventy-base-blog.netlify.com/tags/another-tag/).