Alexander Engelhardt
Alexander Engelhardt

Reputation: 1712

How to change format of page title only for blog posts?

I have a Jekyll website with a number of static pages and a number of blog posts.

On the static pages, my page title is "Site-wide Title | Page Title", which is okay. But on blog posts, I would like the page title to be only the post title, without my site-wide title in front.

The <title> tag is defined in my _includes/head.html, and says {% if page.title %}My website | {{ page.title }}{% else %}{{ site.title }}{% endif %}

  1. How do I set up different formats for pages and posts?
  2. What is site.title? I can't find it in the Jekyll docs

Upvotes: 3

Views: 897

Answers (1)

Mr. Hugo
Mr. Hugo

Reputation: 12592

Use this condition in your head.html:

{% if page.layout == 'post' %}
  {{ page.title }}
{% else %}
  {{ site.title }} | {{ page.title }}
{% endif %}

However, I would recommend to put the 'page.title' in front of the 'site.title'.

Upvotes: 3

Related Questions