Override list.html for specific tag

Hi,

I want to use a specific template when listing some of my tags.

For example if I have a tag called bob.
I have created a bob directory under content/tags with an _index.md file.

[content]
  [tags]
    _index.md
    [bob]
      _index.md

This bob/_index.md file has frontmatter set to override the layout file used.

layout: bob

Under layouts I have created a folder for bob with a list.html file.

[layouts]
  [tags]
    list.html
    [bob]
      list.html

When I navigate to “http://localhost:1313/tags/bob/” it does not use list.html in the bob folder but always instead uses the layouts/tags/list.html file.

Unless I have misunderstood I have tried to follow the solution in this posting:

Any help would be appreciated.

Thanks,
Crawford.

Are you sure tags are declared as taxonomy (by default they are). The answer your are sharing above do not refer to taxonomies but to content types (recipe)

If tags is indeed a taxonomy, /tags/bob will use a term.html template and be of Kind term while /tags will use the taxonomy.html template and be of Kind taxonomy.
So in your layouts/tags directory you can create

taxonomy.html (for /tags page)
term.html (for /tags/bog` page).

This should work. If not try and create the files in layout/_default

Thanks.

I am using default settings so tags will be a taxonomy.
In layouts/tags I can name file list.html or taxonomy.html, both work and are used to list all tags correctly.

Tried renaming layouts/tags/bob/list.html to term.html.
But never uses this. Always uses layouts/tags/list.html.
Should I be setting content/tags/bob/_index.md file with “layout: term” (or variation)?

I can obviously make this work by doing an if else if else if else in layouts/tags/list.html to achieve what I want?
Just thought it was possible (and tidier) to have a specific template for each tag.

Thanks,
Crawford.

Having investigated further I now see how to acceptably achieve what I wanted.

For each tag, create a [tag]/_index.md under [content][tags].
Then add frontmatter / content as required for each tag in their _index.md file.

[content]
  [tags]
    [2021]
      _index.md
    [actors]
      _index.md
    [directors]
      _index.md

Just have a single list.html file under [layouts][tags]. (or taxonomy.html)
Have this refer to frontmatter / content as above.

[layouts]
  [tags]
    list.html

So for my requirements I have no need to have a separate “list.html” for each tag. Will worry about that in the future if ever needed!

Thanks,
Crawford.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.