Search code examples
jekyllgithub-pages

Customizing meta title tag in Just the Docs Jekyll theme


My friends website is made with the Just the Docs Jekyll theme and is hosted on GitHub pages.

Is it possible to change the meta title of the home page without changing the current title which is displayed on the website?

Currently the generated meta title of my friends website is:

<title>Home - Lea Bosshart Text</title>

In the _config.yml file there is following: title: Lea Bosshart Text

On the website it looks like this:

enter image description here


Solution

  • I found the answer by myself

    In the file _includes/head.html I replaced {% seo %} with {% seo title=false %} to disable the <title> output of the jekyll-seo-tag plugin like described here.

    In the file _includes/head_custom.html I added following:

    {% if page.title == "Home" %}
    <title>Lea Bosshart: Text, Übersetzung, Lektorat & Korrektorat</title>
    {% endif %}
    
    {% if page.title != "Home" %}
    <title>{{ page.title }} - {{ site.title }}</title>
    {% endif %}
    

    Its also possible to add a script like the following In the file _includes/head_custom.html:

    <script>document.title = "This is the new page title.";</script>