Search code examples
jekyll

Set <title> attribute of homepage in Jekyll Minima theme


Running the following three shell commands creates a Jekyll site with the default Minima theme and serves it to the browser:

jekyll new test_blog
cd test_blog/
bundle exec jekyll serve

By default, the HTML <title> element of the rendered index page includes both the blog title and the description, so that it appears as follows:

enter image description here

I would like to remove the description and display the only the title. Normally, the way you do this is by copying the default _includes/head.html to your local site directory and modifying the <title> element accordingly. But the default _includes/head.html includes no <title> element to speak of:

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  {%- seo -%}
  <link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
  {%- feed_meta -%}
  {%- if jekyll.environment == 'production' and site.google_analytics -%}
    {%- include google-analytics.html -%}
  {%- endif -%}
</head>

... nor do any of the other files in the basic Minima template, as far as I can tell by grep. I tried adding a line <title>My Literal Title</title> in _includes/head.html as well, but it seems to be get overwritten by something else, because it has no effect on the displayed title.

How can I change the formatting of the homepage title in the Jekyll Minima template?


Solution

  • If modifying _includes/head.html to add a title element, the title will not change if the new title element is added below the {%- seo -%} line. Add it above that line, and the | and description will be removed.

    I tested this on a fresh install of Jekyll and created the _includes/head.html in the directory.