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

Title is not working #134

Open
DrSHendricks opened this issue Jul 28, 2021 · 14 comments
Open

Title is not working #134

DrSHendricks opened this issue Jul 28, 2021 · 14 comments

Comments

@DrSHendricks
Copy link

I was updating my page title today., then it appears that the readme headline shows on the page title rather than the title I set in _config.yml. I cleaned cookies but it is still not working. Can you help, please?

@brettChapman
Copy link

I'm getting the same problem with the title from my _config.yml file not being applied. I'm using the remote_theme. I swap out to other themes and the problem goes away, so it's an issue with the cayman theme v0.2.0.

@channelcharting
Copy link

Anyone with a solution besides changing the theme?

@ddejohn
Copy link

ddejohn commented Aug 22, 2021

Having this issue too.

@crobbo
Copy link

crobbo commented Nov 17, 2021

Same issue here...

@Treahall
Copy link

Treahall commented Dec 2, 2021

Running into the same issue trying to set up a portfolio page.

@jkingslake
Copy link

jkingslake commented Dec 17, 2021

same issue here with the cayman theme in this repo

@BenSouchet
Copy link

Hi guys

I looked into the issue and the only correct solution currently is to "create a custom layout", this is ultra easy and can be done in 1min.
The steps are:

  • On your repo where you have the _config.yml file you need to create a folder named "_layouts/" and in that new folder create a file named "default.html"
  • In that "default.html" past the content of this page.
  • Replace this line <h1 class="project-name">{{ page.title | default: site.title | default: site.github.repository_name }}</h1> with this line <h1 class="project-name">{{ site.title | default: site.github.repository_name }}</h1>
  • And replace this line <h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2> with <h2 class="project-tagline">{{ site.description | default: site.github.project_tagline }}</h2>
  • Save the file ("default.html")
  • Wait approx 2mins for the build of your page to be fully done
  • Voilà

In you want to remove these changes to get back the original behaviour, simply delete the "_layout/" folder (that normally contains the "default.html" file we created.

For advanced users

If you want to understand the issue, this is due to the parsing of the "index.md" file, when parsed the first header title is use to set the page.title variable. In the lines I highlighted in the steps below the behaviour is first to check if the markdown as a title then only if not use the title set by the user (and if there isn't use the repository name).

Why not creating a merge request to fix this issue ?

Currently pages aren't Github priority so current merge request seems to be not checked and merged by maintainers.
Secondly I don't know if it's a bug or not, some theme as this "issue" in the HTML code, some don't have this syntax.

Conclusion

Yes there is something weird in the way the HTML of the page template is done, the documentation here is not correct, the theme don't respect the following variables by default.
But there is a solution, not ideal but still.

@pippim
Copy link

pippim commented Dec 23, 2021

@BenSouchet For myself, it was simple enough to get title working by copying over default.html from Cayman Themes to my own repo. I did not have to do any replacing as your post recommends. I kept the lines:

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

<h2 class="project-tagline">{{ page.description | default: site.description | default: site.github.project_tagline }}</h2>

Not sure why my page started working without doing your recommended changes as you can see on my website: pippim/github.io

To reiterate, at first my title wasn't working either, but copying over default.html appeared to have accidentally fixed it. Perhaps I changed something else and forgot about it 1K commits ago...

@BenSouchet
Copy link

BenSouchet commented Dec 23, 2021

Hi @pippim

This is due to a second workaround, maybe a simpler than my previous message.
To force the variable page.title to be the string you want you can overwrite it at the beginning of your "index.md" file.
To do that you need to add these line at the top of your "index.md" file:

---
title: The title you want for the site
---

This is called front matter YAML syntax, this is used to add and / or overwrite variable used on the front (HTML files and Markdown files)

@pippim you added theses line in your "index.md" file, as you can see in the screenshot below:
Screenshot 2021-12-23 at 11 50 56
So this is why in your case the title "work", I think the copy of "default.html" wasn't necessary.

Info for advanced users

This syntax seems not working currently on HTML layouts file, only working on Markdown (.md) files.
This is weird since the official documentation indicate that it's working on HTML and MD, maybe an issue with BOM and UTF-8 encoding. I haven't properly checked if it's due to UTF-8

@jkingslake
Copy link

@BenSouchet your first work around worked. :-) Thank you for your help!

@wzm2256
Copy link

wzm2256 commented Apr 24, 2022

I have spent the whole night trying to solve this problem..I am both glad and sad to know this is actually not my problem but just a bug...I will check the work around tomorrow.

@shaunyuan22
Copy link

@BenSouchet It finally works! Appreciate ur help, Thanks :)

WrichikBasu added a commit to WrichikBasu/AudioFocusController that referenced this issue Jan 22, 2023
@PaiSolutions
Copy link

This is still a issue for me, will this be fixed or do we have to use work arounds?

@WickiRiama
Copy link

Hello, this is also still an issue for me.

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

No branches or pull requests