Skip to content

Honor implicit page type ("page") when selecting template #13826

@jmooring

Description

@jmooring

In relation to the new template system, this has been discussed before, but I'd like to revisit it.

Consider this project structure:

content/
└── p1.md

layouts/
├── page/
│   └── page.html
└── page.html

When the page type is explicitly set to "page" in front matter, Hugo renders p1.md using layouts/page/page.html as expected.

However, when the page type is implicitly set to "page" Hugo renders p1.md using layouts/page.html instead.

Without digging into the details, I suspect that this method has no impact on template selection:

hugo/hugolib/page__meta.go

Lines 226 to 238 in dd6e2c8

const defaultContentType = "page"
func (p *pageMeta) Type() string {
if p.pageConfig.Type != "" {
return p.pageConfig.Type
}
if sect := p.Section(); sect != "" {
return sect
}
return defaultContentType
}

Reference: https://discourse.gohugo.io/t/possible-bug-single-layout-for-pages-in-v0-147-9/55179/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions