From 75f4d8703e995ca52ab6efffd7f836d57337f41f Mon Sep 17 00:00:00 2001 From: Tony Ho Date: Fri, 6 Jan 2017 19:33:51 +1100 Subject: [PATCH] Add options to configure HTML document title (#154) * Add option to use site title as HTML document title * Add configurable title separator character * Keep old document title behaviour when not using use-site-title --- README.md | 1 + _config.yml | 4 ++++ _includes/head.html | 4 ++-- index.html | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e5ce76..23f150f 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ Parameter | Description ----------- | ----------- title | Page or blog post title subtitle | Short description of page or blog post that goes under the title +use-site-title | If you want to use the site title rather than page title as HTML document title (ie. browser tab title), use `use-site-title: true`. When set, the document title will take the format `Site Title - Site Description` (eg. `My website - A virtual proof that name is awesome!`). By default, it will use `Page Title` if it exists, or `Site Title` otherwise. bigimg | Include a large full-width image at the top of the page. You can either give the path to a single image, or provide a list of images to cycle through (see [my personal website](http://deanattali.com/) as an example). comments | If you want do add Disqus comments to a specific page, use `comments: true`. Comments are automatically enabled on blog posts; to turn comments off for a specific post, use `comments: false`. Comments only work if you set your Disqus id in the `_config.yml` file. show-avatar | If you have an avatar configured in the `_config.yml` but you want to turn it off on a specific page, use `show-avatar: false`. If you want to turn it off by default, locate the line `show-avatar: true` in the file `_config.yml` and change the `true` to `false`; then you can selectively turn it on in specific pages using `show-avatar: true`. diff --git a/_config.yml b/_config.yml index 18982a7..2473872 100644 --- a/_config.yml +++ b/_config.yml @@ -102,6 +102,10 @@ url-pretty: "MyWebsite.com" # eg. "deanattali.com/beautiful-jekyll" # Truncates the excerpt to the specified number of words on the index page excerpt_length: 50 +# Character used to separate site title and description in HTML document title +# and RSS feed title +title-separator: "-" + # --- Don't need to touch anything below here (but you can if you want) --- # # Output options (more information on Jekyll's site) diff --git a/_includes/head.html b/_includes/head.html index 0e22dde..7b2b58b 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -3,7 +3,7 @@ - {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %} + {% if page.use-site-title %}{{ site.title }} {{ site.title-separator }} {{ site.description }}{% elsif page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %} @@ -11,7 +11,7 @@ {% endif %} - + {% if layout.common-ext-css %} {% for css in layout.common-ext-css %} diff --git a/index.html b/index.html index 9e8da19..e297651 100644 --- a/index.html +++ b/index.html @@ -2,6 +2,7 @@ layout: page title: My website subtitle: This is where I will tell my friends way too much about me +use-site-title: true ---