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

Allow site title to be customised via parital #384

Merged
merged 4 commits into from
Sep 27, 2021
Merged

Allow site title to be customised via parital #384

merged 4 commits into from
Sep 27, 2021

Conversation

JackMorganNZ
Copy link
Contributor

This change allows the site's <title> element to easily overridden with a new site-title.html partial, without having to duplicate the entire html-head.html partial. This was raised as a possibility in #175.

The existing template has a lot of logic built in, so when overriding it could lead to issues when updating the theme and forgetting to update the duplicate file.

Use case example: In our project we wish to not show the page title on the homepage, so I can override the site-title.html partial with:

<title>{{ if not .IsHome }}{{ partial "docs/title" . }} | {{ end }}{{ .Site.Title }}</title>

The README was also updated to highlight the theme's existing partials, as well as the empty partials already mentioned. The use of partials throughout has made using this theme a delight.

Keen to hear your thoughts. Thanks for such a useful theme!

JackMorganNZ added a commit to uccser/cs-unplugged-classic that referenced this pull request Sep 22, 2021
html-head.html file can be removed if
alex-shpak/hugo-book/pull/384 is accepted.
Copy link
Owner

@alex-shpak alex-shpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
Good idea! I would like to request some changes, tho.

  • Move <title> tag back to html-head partial, so that content of site-title.html would not mess (or mess less) with html head. Maybe even apply some html escaping.
  • Rename site-title to html-head-title

@JackMorganNZ
Copy link
Contributor Author

Thanks @alex-shpak, great suggestions and have pushed those changes.

I couldn't figure out how to do HTML escaping for the partial import (it's my first time using Go/Hugo). I've enabled 'edits by maintainers' so you can push additional commits to this branch if you wish to add the escaping yourself, or let me know what to change and I can do it.

@alex-shpak
Copy link
Owner

Looks good. I will add escaing if it will become an issue.
Thanks for contribution!

@alex-shpak alex-shpak merged commit 9d4916f into alex-shpak:master Sep 27, 2021
JackMorganNZ added a commit to uccser/cs-unplugged-classic that referenced this pull request Oct 6, 2021
Our previous override is now part of the
theme repo. See:
alex-shpak/hugo-book#384
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 this pull request may close these issues.

2 participants