Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page titles are taken from the first heading if no title exists #633

Open
brownsarahm opened this issue Dec 9, 2021 · 9 comments · May be fixed by #634
Open

Page titles are taken from the first heading if no title exists #633

brownsarahm opened this issue Dec 9, 2021 · 9 comments · May be fixed by #634

Comments

@brownsarahm
Copy link
Contributor

brownsarahm commented Dec 9, 2021

The layout for the page reference says the title should be "References" which is then what the included on all pages main title should use, but somehow it's getting the first heading content in the page's content (not including the "key points" heading which comes from an include) on both instructor training and dc-ecology-python

We have a PR to IT attempting to override this, but it seems like unintended behavior all around?

@maxim-belkin
Copy link
Contributor

I am pretty sure this is due to all of these lessons having "outdated" reference page template: they don't specify the title. Instead of setting the title to "Keypoints and References", I'd suggest to copy the contents of "reference.md" file from this repository verbatim to avoid future merge conflicts when syncing up with the styles repo.

@brownsarahm
Copy link
Contributor Author

_layouts/reference.md in this repo and IT appears to match?

@zkamvar
Copy link
Contributor

zkamvar commented Dec 10, 2021

They do match. I'm not sure what is happening, but I would not be surprised if Jekyll is helpfully filling the page.title element. There should not be any problem with editing the title of reference.md (which does work) since that's not part of the template (it's a generated file).

@zkamvar
Copy link
Contributor

zkamvar commented Dec 10, 2021

This is a problem on pretty much any lesson where reference.md does not have a title: yaml item. Programming with R and Git Novice both show this issue.

@zkamvar
Copy link
Contributor

zkamvar commented Dec 10, 2021

The solution for new lessons would be to add the title header in https://github.com/carpentries/styles/blob/gh-pages/bin/boilerplate/reference.md, but for the other lessons, it might just be to create pull requests that adds the title to the reference pages.

@zkamvar
Copy link
Contributor

zkamvar commented Dec 10, 2021

After running a few tests, it appears that this will affect all of the pages in a lesson that do not have titles. If the first element of a page is a header element, then Jekyll will interpret that as the page.title

Examples

A page without a title element:

---
layout: page
---

Title: {{ page.title }}

## Heading 1 
<p>Title: </p>

<h2>Heading 1</h2>

A page with the title element:

---
layout: page
---

## Heading 1

Title: {{ page.title }}
<h2>Heading 1</h2>

<p>Title: Heading 1</p>

@zkamvar
Copy link
Contributor

zkamvar commented Dec 10, 2021

As I suspected, this is coming from a feature on GitHub pages. They have the jekyll-titles-from-headings plugin enabled (as shown in https://pages.github.com/versions/).

In order to turn this behaviour off, we need to set the following in the _config.yml:

titles_from_headings:
  enabled: false

@maxim-belkin
Copy link
Contributor

_layouts/reference.md in this repo and IT appears to match?

The _layouts directory contains HTML files. I was talking about reference.md in bin/boilerplate.

There should not be any problem with editing the title of reference.md (which does work) since that's not part of the template (it's a generated file).

It's copied from bin/boilerplate when the lesson is created. Perhaps, we should move the common title from the reference.html file in the _layouts folder to .md file in bin/boilerplate.

@maxim-belkin
Copy link
Contributor

I do agree, however, that it should be safe to redefine the title in the file.

@zkamvar zkamvar changed the title Problem with title on reference page? Page titles are taken from the first heading if no title exists Dec 10, 2021
zkamvar added a commit to zkamvar/styles that referenced this issue Dec 10, 2021
There was an issue where GitHub had adopted the
jekyll-titles-from-headings gem in their builds so that pages without
default titles would have the first heading adopted as the page title.
This commit disables that gem so that unintentional titles do not appear.

This will fix carpentries#633
@zkamvar zkamvar linked a pull request Dec 10, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants