Home page ".Type" is unexpected

Here’s a portion of layouts/_default/baseof.html:

{{- $bodyClasses := slice -}}
{{- $bodyClasses = $bodyClasses | append (printf "page-kind-%s" .Kind) -}}
{{- $bodyClasses = $bodyClasses | append (printf "content-type-%s" .Type) -}}
{{- $bodyClasses = $bodyClasses | append (cond .IsDraft "draft" "not-draft") -}}
<body class="{{ delimit $bodyClasses ` ` }}"></body>

When the home page is rendered:

<body class="page-kind-home content-type-page not-draft">

Note that the content type is page. Conceptually the home page doesn’t have a content type; it’s the home page. Why is this a problem?

I typically create a “page” content type for static pages (about, contact, etc.). Any style I apply using the .content-type-page class selector will apply to the home page as well as about, contact, etc. This is unexpected and not desirable.

Seems to me that the home page .Type should be home. Thoughts?

Since https://gohugo.io/news/0.18-relnotes/ released, everytihng is a Page.
It’s better using .Kind to differentiate between Page’s kind.
Or combination of both .Type and .Kind.

1 Like

Also see https://gohugo.io/templates/section-templates/#page-kinds .

.Type returns “post” for anything in /post.
.Type returns “article” for anything in /article.
.Type returns “tags” when viewing the “tags” taxonomyTerm page.

Clearly, not everything is a “page” when it comes to content types (.Type).

See Template lookup order | Hugo

Type
Is value of type if set in front matter, else it is the name of the root section (e.g. “blog”). It will always have a value, so if not set, the value is “page”.

That’s the documentation I was looking for. Thanks! I’ll just set type = "home" in the front matter in /_index.md to avoid the collision between the default value of page and the explicit content type of page elsewhere in the site.