hugo-theme-puppet icon indicating copy to clipboard operation
hugo-theme-puppet copied to clipboard

Title tag not rendered on Index page

Open daemotron opened this issue 2 years ago • 0 comments

On the root index.html, the title tag within the head remains empty.

<!doctype html>
<html lang=en>
<head>
<meta name=generator content="Hugo 0.109.0">
<meta charset=utf-8>
<meta http-equiv=x-ua-compatible content="ie=edge">
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title></title>

On blog posts it's filled correctly - this behaviour can also be observed on the sample site (https://hugo-theme-puppet.netlify.app/)

One possible solution: Add a title property (matching the site's title) to the front matter of _index.md in the root of content (https://github.com/roninro/hugo-theme-puppet/blob/master/exampleSite/content/_index.md).

Another possible solution would be to adapt the conditional in baseof.html and add a case for .IsHome, setting $title to .Site.Title:

{{ $title := .Title }}
{{- if not .IsHome }}
    {{ $title = printf "%s | %s" .Title .Site.Title }}
{{ else }}
    {{ $title = printf "%s" .Site.Title }}
{{ end -}}

<title>{{ $title }}</title>

daemotron avatar Jan 03 '23 19:01 daemotron