danurbanowicz / eleventy-netlify-boilerplate

A template for building a blog with the Eleventy static site generator and Decap CMS
https://eleventy-netlify-boilerplate.netlify.app/
MIT License
528 stars 182 forks source link

Default title for tag page #14

Closed spekulatius closed 5 years ago

spekulatius commented 5 years ago

Hello @danurbanowicz

I was wondering if you could give me a hint on how to change the default title for the tag pages. I've tried to add different versions of "title" to the front of the tags.njk-file but non succeeded.

Cheers, Peter

danurbanowicz commented 5 years ago

Page titles are set in _includes/components/head.njk

Currently it just pulls in the default site title from data/metadata.json

Assuming you want to output some text and then the tag name as your page title, you need to use the renderData method in your tags.njk front matter, something like this:-

renderData:
  title: "Posts tagged: {{ tag | capitalize }}"

Then in _includes/components/head.njk you can do the following to use it if it's a tag page:-

<title>{{ renderData.title or title }}</title>

Sorry it's a rushed explanation, I will try to get a PR done soon to implement this as default behaviour.

danurbanowicz commented 5 years ago

Fixed by PR #15