From c77fab87022d5003eaf2129d46aab1e524ea1c9e Mon Sep 17 00:00:00 2001 From: dojineko Date: Wed, 3 Jan 2018 16:34:49 +0900 Subject: [PATCH 1/2] add titleDelimiter --- exampleSite/config.toml | 6 ++++++ layouts/partials/head.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 1356cf7cf..8de0c98af 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -104,6 +104,12 @@ canonifyurls = true # Default format is: January 2, 2006 # dateFormat = "2 January 2006" + # Custom title delimiter use to render blog post format + # This parameter affect to pages except home page + # If empty it will be title only + # e.g. - + # titleDelimiter = " - " + # Global keywords configuration. Following keywords will be add to every pages # keywords = ["development", "next-gen"] diff --git a/layouts/partials/head.html b/layouts/partials/head.html index fabc8fcfe..840a1e7a6 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,7 +26,7 @@ {{ partial "head_start.html" . }} {{ partial "meta.html" . }} - {{ with .Title }}{{ . }}{{ else }}{{ .Site.Title }}{{ end }} + {{ if and (ne .Kind "home") .Title .Site.Params.titleDelimiter }}{{ .Title }}{{ .Site.Params.titleDelimiter }}{{ .Site.Title }}{{ else if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }} {{ with .RSSLink }} From fd3424eb48dc067cf1030860563687cacba2d243 Mon Sep 17 00:00:00 2001 From: dojineko Date: Thu, 4 Jan 2018 00:11:54 +0900 Subject: [PATCH 2/2] use replace function --- exampleSite/config.toml | 5 ++--- layouts/partials/head.html | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8de0c98af..14f44f21e 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -104,11 +104,10 @@ canonifyurls = true # Default format is: January 2, 2006 # dateFormat = "2 January 2006" - # Custom title delimiter use to render blog post format + # Customize title format # This parameter affect to pages except home page # If empty it will be title only - # e.g. - - # titleDelimiter = " - " + # titleFormat = "$pageTitle - $siteTitle" # Global keywords configuration. Following keywords will be add to every pages # keywords = ["development", "next-gen"] diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 840a1e7a6..90de4304c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,7 +26,7 @@ {{ partial "head_start.html" . }} {{ partial "meta.html" . }} - {{ if and (ne .Kind "home") .Title .Site.Params.titleDelimiter }}{{ .Title }}{{ .Site.Params.titleDelimiter }}{{ .Site.Title }}{{ else if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }} + {{ if and (ne .Kind "home") .Title .Site.Params.titleFormat }}{{ replace (replace .Site.Params.titleFormat "$pageTitle" .Title) "$siteTitle" .Site.Title }}{{ else if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }} {{ with .RSSLink }}