Skip to content

Commit

Permalink
Merge pull request #51 from dlemm/fix/browser-tab-title-for-404
Browse files Browse the repository at this point in the history
Feature: Adjust Page title according to page and title
  • Loading branch information
peterschewe authored Dec 14, 2022
2 parents b4fee92 + 1bbdfab commit f8ac8b5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions hugo-modules/core/utils/seo/private/get-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@
{{/* Title
----------------------------
We use the following logic
1. Every pages: `Page title | Global site title`
2. Homepage: only `Global site title` */}}
1. Every page: `Page title | Global site title`
2. On 404 Page: `404 | Global site title`
3. If no title is set, the `Global site title` is used
4. Homepage: only `Global site title` */}}
{{ $title := "" }}
{{ with .Params.title }}
{{ $title = . }}
Expand All @@ -101,10 +103,20 @@
{{ $title = . }}
{{ end }}
{{ if not .IsHome }}
{{/* 1. `Page title | Global site title` */}}
{{ $s.SetInMap "seo" "title" (printf "%s | %s" $title $settings.title) }}
{{ with $title }}
{{/* 1. `Page title | Global site title` */}}
{{ $s.SetInMap "seo" "title" (printf "%s | %s" $title $settings.title) }}
{{ else }}
{{/* 2. `404 | Global site title` */}}
{{ if eq $.Page.Kind "404" }}
{{ $s.SetInMap "seo" "title" (printf "%s | %s" "404" $settings.title) }}
{{ else }}
{{/* 3. `Global site title` */}}
{{ $s.SetInMap "seo" "title" $settings.title }}
{{ end }}
{{ end }}
{{ else }}
{{/* 2. `Global site title` */}}
{{/* 4. `Global site title` */}}
{{ $s.SetInMap "seo" "title" $settings.title }}
{{ end }}

Expand Down

0 comments on commit f8ac8b5

Please sign in to comment.