Title for Tag page and Pagination

Hello All,
I am looking in way to add a word to the title for Tag page and for Pagination (in the <head>)

The issue

In Google Analytics 4 by default sites are displayed by Title rather than /path/ like it used to be in Universal Analytics. You can change this in reports but on mobile by default is by Title


If you visit page /tag/openwrt/ the title in my instance will display OpenWrt

If you visit /category/openwrt than the title will display OpenWrt as well.

Where for categories I can sort this through frontmatter specific for category in content folder


title: "Posts in category OpenWrt"

With Tags its not as easy.
I don’t want to create frontmatter for all different tags as that’s crazy a bit

I have been looking into that:

but doesn’t seems to be working for me.

 <title>{{ if .IsHome }}{{ .Site.Title }} – {{ .Site.Params.description }}{{ else if eq .Kind "taxonomy" }}Pages with Tag: {{ . }} – {{ else }}{{ with .Title }}{{ . }} – {{ end }}{{ .Site.Title }}{{ end }}</title>

The other part of the question, how to specify Title for pagination pages

For example /page/2/ inherit title from the homepage but would like to add something to read like

where is for Homepage


what would like for pagination from homepage - Page 2

<title>Homepage - Page 2</title>

I might be misunderstanding your problem, but I add these words to my tags page by adding it to the template _default/term.html. term.html is your “list”-page for tag X.

<h1 class="post-title">Posts tagged with #{{ .Title }}</h1>

Same goes with pagination. Within the pagination you have a whole dict of info available per page.

The best I can describe it is with links into my repositories:

  1. Create the pagination BEFORE anything else and scratch it here.
  2. At the point where you wish to show the title for the pagination (in my case the title tag) load the pagination from scratch and use the pagination template info here.

The problem with the pagination is that you can create it only once, so I myself created this routine where at the first line in the basetemplate I create the pagination object for the current page, then later on only load if from scratch to work with it. This is what scratch was made for ;)… probably.

how to specify Title for pagination pages

long story short: at that place, load your pagination object, then check if you are on a page >1 and if so then add the text part.

Thanks but it’s about <title> in <head> rather than on page itself.

I think I know how to get this for tags using path based approach and think that same will do for pagination but would be good to maintain a number in title as well rather than static text.

Will share my approach later on.

The title tag in the head on this page has a (Page 2) in it, so I must have been doing something right. Waiting for your solution.

1 Like

Though it will be simple, is not and sorry, but cannot sort out how to borrow it from your website.

Sort it out for Tags

  <title>{{ if .IsHome }}{{ .Site.Title }} – {{ .Site.Params.description }}{{ else }}{{ if in .Permalink "/tag/" }}Tag: {{ end }}{{ with .Title }}{{ . }} – {{ end }}{{ .Site.Title }}{{ end }}</title>

but not pagination

For the tags, maybe this will help:

Which for a tag would have a title like:

Tag: your tag

Obviously if you view that repo you could see the full implementation, but I think that is the important bit.

No idea on pagination, I haven’t worried about that before.

The not .File allows a title from a hand-crafted tags Markdown file to be respected.