Adding front matter to tags/category rollup pages

I suspect that you are having collisions from your tags defined in content/tags/tag/_index.md files.

Assuming defaults and minimal configs:

Having content/posts/one.md with

tags:
  - foo bar

will generate a tags listing page at yoursite.com/tags/foo-bar/ by default.

Having content/tags/Foo Bar/_index.md will also generate a page at yoursite.com/tags/foo-bar/.

These two are not the same “Page” however. You can test this out by adding the following lines to your list layout:

{{.Page}}
<br>
{{.Pages}}

Run hugo server. Navigate to and observe /tags/foo-bar/ locally, while saving a file a few times to trigger a few Hugo builds, and you probably see different values printed:

Page(/tags/foo bar/_index.md)
Pages(0)

and

Page(/tags/foo-bar)
Pages(2)

My suggestion would be to try to keep the content/tags/tag/_index.md file names the way Hugo expects them to look (ie foo-bar instead of Foo Bar) and see if you still get collisions.

2 Likes