Eleventy: Tagging tags

Created on 19 Jul 2018  路  6Comments  路  Source: 11ty/eleventy

Hi, I have a use case for which I would like to tag tags, so that I can build a network of tags. Just like categories in Wikipedia can be attached to other categories.

My current code (based on the blog template) is in https://github.com/nhoizey/web-tldr.com and I use Netlify to build it: https://web-tldr.com/

I didn't yet find a way to tag tags and build the pages that show that.

I started with a tags/ folder in which I put .md files, but the blog template already builds tag pages, so it didn't work.

I've moved the <tag>.md file into _data/tags/ (example), but I don't know how to use it to "fill" the /tags/<tag>/index.html page.

Also, I would like to list:

  • "root" tags, which are not tagged
  • all tags that have one specific tag (like tag pages list posts with that tag)

Is there any example I could follow, or advice?

Thanks

education open-question

Most helpful comment

I sounds a bit like parent and child tags? Might be wrong, just guessing.

All 6 comments

Couple of things before I dive in here just to level set:

  • The tags pages on eleventy-base-blog are generated from tags.njk. You can just delete that template if you want to use the tags/ directory for something else. OR change the permalink front matter in there to map to a different directory (currently permalink: /tags/{{ tag }}/)
  • The _data folder only accepts JSON files right now. Any other files in there are ignored.

I鈥檓 not completely sure I understand the use case here though. Can you walk me through an example of a specific topic on Wikipedia that you鈥檙e trying to emulate?

Oh you want to build tag relationships, right?

Like stroke-width is related to the svg tag, in your demo?

I sounds a bit like parent and child tags? Might be wrong, just guessing.

Sounds like you might want to use a dependency graph? https://www.npmjs.com/package/dependency-graph

You could build your network of related tags using the dependency-graph library and then use Eleventy collections (https://www.11ty.io/docs/collections/) withaddCollection to create new collections of content related to that specific tag?

Just an idea

Wow, I think I didn't receive any notification indicating you had answered, sorry.

It kind of looks like a dependency graph, indeed, I'll try this, and let you know, thanks!

Great, please reopen when you check back鈥攖hanks!

Was this page helpful?
0 / 5 - 0 ratings