Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use per-page title with a Jekyll theme

This is my personal GH Pages site.

I have this set in my /_config.yml:

theme: jekyll-theme-cayman

title: iBug @ GitHub
description: The small personal site for iBug

Now it shows a big title iBug @ GitHub and a tagline on every page GH Pages generates. I want to set overrides for specific pages. I tried

---
title: Blog index
---

in /blog/index.html, but it doesn't work. It only changes the HTML title of the page (browser title bar), but not the "title" in the big block on the top of the page.

How do I set an override title for a single page?

like image 886
iBug Avatar asked Mar 01 '18 23:03

iBug


People also ask

How do I change the title of a GitHub page?

Changing the title and description You can change the title by editing the _config. yml file in your repository. You can also add a description for your site.


2 Answers

Update: I have since submitted a pull request to change this in the theme, and the answer below is no longer necessary since it's already been applied when you use the theme as of now. All you need to do is to specify the title override in the front matter:

---
title: My custom title
---

To specify another title, you need to change the layout file.

Copy the default layout and place it in <GitHub repo>/_layouts/default.html, and change line 16 to this:

<h1 class="project-name">{{ page.title | default: site.title }}</h1>

Then Jekyll will respect the title set in the front matter, and place it there.

like image 199
iBug Avatar answered Oct 25 '22 18:10

iBug


This is just the way this theme is implemented, if you check the default layout for Cayman theme on line 14 you can see what exact variable it is using.

<h1 class="project-name">{{ site.title | default: site.github.repository_name }}</h1>

Hope that helps!

like image 1
Mario Nikolaus Avatar answered Oct 25 '22 19:10

Mario Nikolaus