You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Jekyll plugin to pull the page title from the first Markdown heading when none is specified.
What it does
If you have a Jekyll page that doesn't have a title specified in the YAML Front Matter, but the first non-whitespace line in the page is a Markdown H1 / H2 / H3, this plugin instructs Jekyll to use that first heading as the page's title.
Why
Because lots of plugins and templates rely on page.title.
If you're using a plugin like Jekyll Optional Front Matter, you'd have to add Front Matter, just to get the title, which you're already specifying in the document.
Additionally, this allows you to store the title semantically, in the document itself so that it's readable, both as Markdown and when rendered, as machine-readable for plugins like Jekyll SEO Tag.
Usage
Add the following to your site's Gemfile:
gem'jekyll-titles-from-headings'
Add the following to your site's config file:
plugins:
- jekyll-titles-from-headings
Note: If you are using a Jekyll version less than 3.5.0, use the gems key instead of plugins.
Configuration
Configuration options are optional and placed in _config.yml under the titles_from_headings key. They default to:
If you want to enable this plugin for collection items, set the collections option to true.
Since collection items (including posts) already have a title inferred from their filename, this option changes the behavior of this plugin to override the inferred title. The inferred title is only used as a fallback in case the document doesn't start with a heading.
Disabling
Even if the plugin is enabled (e.g., via the :jekyll_plugins group in your Gemfile) you can disable it by setting the enabled key to false.