Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to .Type = "page" when empty #6805

Closed
shantanugoel opened this issue Jan 26, 2020 · 5 comments
Closed

Revert to .Type = "page" when empty #6805

shantanugoel opened this issue Jan 26, 2020 · 5 comments
Labels
Milestone

Comments

@shantanugoel
Copy link

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.63.1/extended darwin/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes

The home page is supposed to be a "page" as mentioned here https://gohugo.io/templates/homepage/
However, from 0.63.0 onwards, the .Type for homepage does not return page anymore, rather blank. I believe this is a side effect of #6760

This was discovered via my use of the beautifulhugo theme, which has this code to select appropriate styling for the subtitle depending on whether a page or post is being generated: https://github.com/halogenica/beautifulhugo/blob/1ff3894b84b1802433b58e22dd22f4eb46a49fa9/layouts/partials/header.html#L70

Before 0.63.0, it generates "page-subheading" as the class as can be seen on https://shantanugoel.com/
0.63.0 onwards, it generates "-subheading" as the class.

@bep
Copy link
Member

bep commented Jan 26, 2020

The home page is supposed to be a "page" as mentioned here https://gohugo.io/templates/homepage/

I don't see anything about this on the page you link to. I don't see anything anywhere in the docs about this.

The .Type gets the value from either 1) Frontmatter or if not set 2) The .Section. It's in the release notes.

@bep bep closed this as completed Jan 26, 2020
@bep bep reopened this Jan 26, 2020
@bep
Copy link
Member

bep commented Jan 26, 2020

Thinking about this and the reasons behind #6760 are probably not important enough considering the potential for problems with existing sites. I did check the documentation before doing this and assumed this was a hidden and unused feature.

@bep bep changed the title HomePage type is returned as blank Revert to .Type = "page" when empty Jan 26, 2020
@bep bep added this to the v0.63.2 milestone Jan 26, 2020
@shantanugoel
Copy link
Author

Thanks for considering this. Just for completion sake, wrt your comment

I don't see anything about this on the page you link to. I don't see anything anywhere in the docs about this.

This is what the link I mentioned says:

Homepage is a Page and therefore has all the page variables and site variables available for use.

which I interpreted to mean that it should have the .Type as page.

bep added a commit to bep/hugo that referenced this issue Jan 26, 2020
This was changed with good intentions in 0.63.0.

This behaviour was not documented, but it was of course in use.

This commit rolls back to how it behaved before:

For `Page.Type` you will get:

* `type` from front matter if set.
`* `.Section`
* If none of the above returns anything, return "page"

Fixes gohugoio#6805
@bep
Copy link
Member

bep commented Jan 26, 2020

which I interpreted to mean that it should have the .Type as page.

I admit it can be confusing, but those terms are not the same. .Type defaults to the section if not set with type in front matter (e.g. first path ... blog, posts, docs). The home page lives in the root folder, so it doesn't have a .Section.

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants