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
7 ■■■■■ changed files
docs/configurations.md 4 ●●● patch | view | raw | blame | history
layouts/_default/baseof.html 3 ●●●● patch | view | raw | blame | history
docs/configurations.md
@@ -127,7 +127,7 @@
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"`                  |
@@ -155,6 +155,8 @@
| 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>