mirror of https://github.com/luizdepra/hugo-coder.git

Paolo Mainardi
17.40.2025 0bc26e3a935035a38781c20b9b744a3de357f77c
feat: custom head title (#950)

### Prerequisites

Put an `x` into the box(es) that apply:

- [ ] This pull request fixes a bug.
- [x] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

This PR makes it possible to configure a custom head title, without
having to override the baseof template.

### Issues Resolved

https://github.com/luizdepra/hugo-coder/issues/811

### Checklist

Put an `x` into the box(es) that apply:

#### General

- [ ] Describe what changes are being made
- [ ] Explain why and how the changes were necessary and implemented
respectively
- [ ] Reference issue with `#<ISSUE_NO>` if applicable

---------

Co-authored-by: Luiz F. A. de PrĂ¡ <luizdepra@users.noreply.github.com>
2 files modified
63 ■■■■ changed files
docs/configurations.md 60 ●●●● patch | view | raw | blame | history
layouts/_default/baseof.html 3 ●●●● patch | view | raw | blame | history
docs/configurations.md
@@ -126,35 +126,37 @@
These are all the parameters used by `hugo-coder` theme.
| Name                          | Type   | Required | Description                                      | Default                          | Example                                          |
| ----------------------------- | ------ | -------- | ------------------------------------------------ | -------------------------------- | ------------------------------------------------ |
| author                        | string | Yes      | Author name.                                     |                                  | `"John Doe"`                                     |
| info                          | string | Yes      | An headline, job title or similar.               |                                  | `"Full Stack Developer"`                         |
| description                   | string | Yes      | Description of the site.                         |                                  | `"John Doe's personal website"`                  |
| keywords                      | string | Yes      | Site keywords.                                   |                                  | `"blog,developer,personal"`                      |
| avatarURL                     | string | No       | Photo of the author.                             |                                  | `"images/avatar.jpg"`                            |
| gravatar                      | string | No       | Gravatar photo of the author                     |                                  | `"john.doe@example.com"`                         |
| fediverseCreator              | string | No       | The author's fediverse handle.                   |                                  | `"@johndoe@example.com"`                         |
| faviconSVG                    | string | No       | Custom path to a SCG favicon.                    | `"/img/favicon.svg"`             | `"/img/favicon.svg"`                             |
| favicon_32                    | string | No       | Custom path to a 32x32 favicon.                  | `"/img/favicon-32x32.png"`       | `"/img/favicon-32x32.png"`                       |
| favicon_16                    | string | No       | Custom path to a 16x16 favicon.                  | `"/img/favicon-16x16.png"`       | `"/img/favicon-16x16.png"`                       |
| touchIcon                     | string | No       | Custom path to an apple-touch-icon                      | `"/images/apple-touch-icon.png"` | `"/images/apple-touch-icon.png"`                 |
| mask_icon                     | string | No       | Custom path to a mask-icon                      | `"/images/safari-pinned-tab.svg"` | `"/images/safari-pinned-tab.svg"`                 |
| mask_icon_color                     | string | No       | Custom color for mask-icon color                      | `"#5bbad5"` | `"#5bbad5"`                 |
| since                         | string | No       | Date shown in the footer before now year         |                                  | `"2020"`                                         |
| maxSeeAlsoItems               | number | No       | Series see also post count                       | `5`                              | `10`                                             |
| commit                        | string | No       | Show the last git commit in the footer           |                                  | `"https://github.com/luizdepra/hugo-coder/tree/"`|
| rtl                           | bool   | No       | Enable the Right To Left mode.                   | `false`                          | `true` or `false`                                |
| math                          | bool   | No       | Enable MathJax Module and add JS into your site. | `false`                          | `true` or `false`                                |
| katex                         | bool   | No       | Enable KaTeX for all content types.              | `false`                          | `true` or `false`                                |
| colorScheme                   | string | No       | Specify light/dark colorscheme                   | `"auto"`                         | `"auto"` or `"light"` or `"dark"`                |
| hideColorSchemeToggle         | bool   | No       | If true, hides the color scheme toggle            | `false`                          | `true` or `false`                                |
| customCSS                     | list   | No       | Add extra CSS files to the website.              | []                               | `["css/extra-style.css"]`                        |
| customSCSS                    | list   | No       | Add extra SCSS files to the website.             | []                               | `["scss/extra-style.scss"]`                      |
| customJS                      | list   | No       | Add extra JS files to the website.               | []                               | `["js/extra-script.js"]`                         |
| customRemoteJS                | list   | No       | Add extra remote JS files to the website.        | []                               | `["https://www.example.com/file.js"]`            |
| enableTwemoji                 | bool   | No       | Adds support for Twemoji                         | `false`                          | `true` or `false`                                |
| disableDefaultJsScripts       | bool   | No       | If true, disables default js scripts (coder.js)  | `false`                          | `true` or `false`                                |
| Name                    | Type   | Required | Description                                                              | Default                           | Example                                           |
| ----------------------- | ------ | -------- | ------------------------------------------------------------------------ | --------------------------------- | ------------------------------------------------- |
| author                  | string | Yes      | Author name.                                                             |                                   | `"John Doe"`                                      |
| info                    | string | Yes      | An headline, job title or similar.                                       |                                   | `"Full Stack Developer"`                          |
| description             | string | Yes      | Description of the site.                                                 |                                   | `"John Doe's personal website"`                   |
| keywords                | string | Yes      | Site keywords.                                                           |                                   | `"blog,developer,personal"`                       |
| avatarURL               | string | No       | Photo of the author.                                                     |                                   | `"images/avatar.jpg"`                             |
| gravatar                | string | No       | Gravatar photo of the author                                             |                                   | `"john.doe@example.com"`                          |
| fediverseCreator        | string | No       | The author's fediverse handle.                                           |                                   | `"@johndoe@example.com"`                          |
| faviconSVG              | string | No       | Custom path to a SCG favicon.                                            | `"/img/favicon.svg"`              | `"/img/favicon.svg"`                              |
| favicon_32              | string | No       | Custom path to a 32x32 favicon.                                          | `"/img/favicon-32x32.png"`        | `"/img/favicon-32x32.png"`                        |
| favicon_16              | string | No       | Custom path to a 16x16 favicon.                                          | `"/img/favicon-16x16.png"`        | `"/img/favicon-16x16.png"`                        |
| touchIcon               | string | No       | Custom path to an apple-touch-icon                                       | `"/images/apple-touch-icon.png"`  | `"/images/apple-touch-icon.png"`                  |
| mask_icon               | string | No       | Custom path to a mask-icon                                               | `"/images/safari-pinned-tab.svg"` | `"/images/safari-pinned-tab.svg"`                 |
| mask_icon_color         | string | No       | Custom color for mask-icon color                                         | `"#5bbad5"`                       | `"#5bbad5"`                                       |
| since                   | string | No       | Date shown in the footer before now year                                 |                                   | `"2020"`                                          |
| maxSeeAlsoItems         | number | No       | Series see also post count                                               | `5`                               | `10`                                              |
| commit                  | string | No       | Show the last git commit in the footer                                   |                                   | `"https://github.com/luizdepra/hugo-coder/tree/"` |
| rtl                     | bool   | No       | Enable the Right To Left mode.                                           | `false`                           | `true` or `false`                                 |
| math                    | bool   | No       | Enable MathJax Module and add JS into your site.                         | `false`                           | `true` or `false`                                 |
| katex                   | bool   | No       | Enable KaTeX for all content types.                                      | `false`                           | `true` or `false`                                 |
| colorScheme             | string | No       | Specify light/dark colorscheme                                           | `"auto"`                          | `"auto"` or `"light"` or `"dark"`                 |
| hideColorSchemeToggle   | bool   | No       | If true, hides the color scheme toggle                                   | `false`                           | `true` or `false`                                 |
| customCSS               | list   | No       | Add extra CSS files to the website.                                      | []                                | `["css/extra-style.css"]`                         |
| customSCSS              | list   | No       | Add extra SCSS files to the website.                                     | []                                | `["scss/extra-style.scss"]`                       |
| customJS                | list   | No       | Add extra JS files to the website.                                       | []                                | `["js/extra-script.js"]`                          |
| customRemoteJS          | list   | No       | Add extra remote JS files to the website.                                | []                                | `["https://www.example.com/file.js"]`             |
| enableTwemoji           | bool   | No       | Adds support for Twemoji                                                 | `false`                           | `true` or `false`                                 |
| disableDefaultJsScripts | bool   | No       | If true, disables default js scripts (coder.js)                          | `false`                           | `true` or `false`                                 |
| HeadTitle               | string | No       | When configured, it overrides the `<title>` tag with the provided string | ""                                | `"My custom title"`                               |
### Social Icons Configuration
layouts/_default/baseof.html
@@ -2,7 +2,7 @@
<html lang="{{ .Site.Language.Lang }}">
<head>
  <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
  <title>{{ block "title" . }}{{ .Site.Params.HeadTitle | default .Site.Title }}{{ end }}</title>
  {{ partial "head.html" . }}
</head>
@@ -134,5 +134,4 @@
  {{- partial "body/extensions" . -}}
</body>
</html>