I just finished overhauling my tag system in Eleventy, and figured it was worth a quick write-up since there are a couple of gotchas — especially if you're mixing Markdown and Nunjucks.
Problem
I wanted clean URLs for tags, like /tags/journal/
, and per-tag pages with a nice title.
I also wanted each tag page to have something like tag:devops
as the title.
But when I tried adding title {{ tag }}
to the front matter, I got [object Object]
as the page title.
Solution
Turns out front matter fields like title:
don't evaluate Nunjucks or Liquid. But permalink:
does.
So instead, I discovered eleventyComputed:
eleventyComputed:
title: "Tagged:{{ tag }}"
BAM Now I have dynamic titles in my tag page!