From 602a71e5938701c958176b461e1192124cb1e323 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 11 Dec 2022 02:01:53 -0800 Subject: [PATCH] Unify HTML and RSS titles --- README.md | 3 ++- exampleSite/content/_index.md | 1 - layouts/_default/home.html | 10 +++++++--- layouts/partials/paige_head.html | 2 +- layouts/partials/paige_link.html | 5 ++++- layouts/partials/paige_title.html | 16 ++++++++++++---- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5ec0f4cf..f646e155 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ The HTML keywords is a union of the page keywords, tags, and categories. The HTML title is the page title, followed by a middle dot, followed by the site title. If one is missing, the other is used without the middle -dot. If both are the same, only one is used without the middle dot. +dot. If both are the same for the home page, the title is the page +title. The HTML body can have a header, a body, and a footer. The header has the section menus, if any; the page title, if any; the page description, diff --git a/exampleSite/content/_index.md b/exampleSite/content/_index.md index 65489a83..15bb39cf 100644 --- a/exampleSite/content/_index.md +++ b/exampleSite/content/_index.md @@ -3,7 +3,6 @@ blurb: There's a new daddy in town. A discipline daddy. If I make this comeback, description: Go ahead, touch the Cornballer greeting: You know [best](https://www.youtube.com/watch?v=1WDW8XKEGgU) stretch: stretch.jpg -title: No Borders, No Limits ---

diff --git a/layouts/_default/home.html b/layouts/_default/home.html index 77c4a99e..27a7556d 100644 --- a/layouts/_default/home.html +++ b/layouts/_default/home.html @@ -1,10 +1,14 @@ {{ define "main" }} -{{ if .Title }} +{{ $title := .Title }} +{{ if not $title }} +{{ $title = .Site.Title }} +{{ end }} +{{ if $title }}

{{ if .Params.link }} - {{ .Title | markdownify }} + {{ $title | markdownify }} {{ else }} - {{ .Title | markdownify }} + {{ $title | markdownify }} {{ end }}

{{ end }} diff --git a/layouts/partials/paige_head.html b/layouts/partials/paige_head.html index 4943adc0..df7f5ee2 100644 --- a/layouts/partials/paige_head.html +++ b/layouts/partials/paige_head.html @@ -1,6 +1,6 @@ {{ partial "paige_meta.html" . }} - {{ partial "paige_title.html" . }} + {{ partial "paige_title.html" . }} {{ partial "paige_link.html" . }} {{ partial "paige_style.html" . }} {{ if templates.Exists "partials/paige_head_last.html" }} diff --git a/layouts/partials/paige_link.html b/layouts/partials/paige_link.html index 9b576ec8..a6070df4 100644 --- a/layouts/partials/paige_link.html +++ b/layouts/partials/paige_link.html @@ -3,6 +3,9 @@ {{ if or .Site.Params.math .Params.math }} {{ end }} +{{ if .AlternativeOutputFormats }} +{{ $title := partial "paige_title.html" . }} {{ range .AlternativeOutputFormats }} - + +{{ end }} {{ end }} diff --git a/layouts/partials/paige_title.html b/layouts/partials/paige_title.html index f1538053..c4004991 100644 --- a/layouts/partials/paige_title.html +++ b/layouts/partials/paige_title.html @@ -1,7 +1,15 @@ -{{ if and (and .Title .Site.Title) (or (not (eq .Title .Site.Title)) (not .IsHome)) }} -{{ .Title | markdownify | plainify | htmlUnescape }} · {{ .Site.Title | markdownify | plainify | htmlUnescape }} +{{ $title := "" }} +{{ $pageTitle := .Title | markdownify | plainify | htmlUnescape }} +{{ $siteTitle := .Site.Title | markdownify | plainify | htmlUnescape }} +{{ if and .Title .Site.Title }} +{{ if .IsHome }} +{{ $title = $pageTitle }} +{{ else }} +{{ $title = printf "%s ยท %s" $pageTitle $siteTitle }} +{{ end }} {{ else if .Title }} -{{ .Title | markdownify | plainify | htmlUnescape }} +{{ $title = $pageTitle }} {{ else if .Site.Title }} -{{ .Site.Title | markdownify | plainify | htmlUnescape }} +{{ $title = $siteTitle }} {{ end }} +{{ return $title }}