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

Only auto-create sections for home and first level #6171

Closed
bep opened this issue Aug 6, 2019 · 6 comments
Closed

Only auto-create sections for home and first level #6171

bep opened this issue Aug 6, 2019 · 6 comments
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Aug 6, 2019

I'm in the process of a simplification of how we create the "page tree" (and especially the section tree) in preparation for #6041 -- but also needed for the things coming ahead.

This is mostly code simplification which also should (probably) make it a little faster. But there is one part of the "section logic" that I will remove. Both because it is complicated and hard to maintain, but also because I suspect many people don't like the current behaviour, and it's kind of impossible to opt-out off.

Currently, with this tree:

content
├── a
│   └── b
│       └── c
│           └── d
│               └── _index.md
└── b
  • Hugo will create a section for a/b/c/d because it has a "_index.*" content file.
  • Hugo will also create sections for a, a/b, a/b/c and b.
  • Hugo will also create a home page (aka the root section).

With the new simplified behaviour, Hugo will only "auto create" sections for the home page and the top level folders.

So in the example above, home page and a and b will be "auto created", a/b/c/d will be a section because of its _index.md file.

Also related:

#6153
#6154

@bep bep self-assigned this Aug 6, 2019
@bep bep added the Enhancement label Aug 6, 2019
@bep bep added this to the v0.57 milestone Aug 6, 2019
@kaushalmodi
Copy link
Contributor

So in the example above, home page and a and b will be "auto created", a/b/c/d will be a section because of its _index.md file.

Sounds fair.. so if one needs to retain the auto-creation of a/b and a/b/c, they simply need to create those two _index.md that I show below with the sign, right?

content
├── a
│   └── b
│       ├── _index.md†
│       └── c
│           ├── _index.md†
│           └── d
│               └── _index.md
└── b

@kaushalmodi
Copy link
Contributor

kaushalmodi commented Aug 6, 2019

@bep So from your content tree structure:

content
├── a
│   └── b
│       └── c
│           └── d
│               └── _index.md
└── b

below is a good summary?

Created right now? Will be created after this change?
Hugo will create a section for a/b/c/d, because it has a content file. Yes Yes
Hugo will also create sections for a and b, because they are top level folders. Yes Yes
Hugo will also create a home page (aka the root section). Yes Yes
Hugo will also create sections for a/b and a/b/c. Yes No, because they do not have any content _index.md file.

@bep
Copy link
Member Author

bep commented Aug 6, 2019

Sounds fair.. so if one needs to retain the auto-creation of a/b and a/b/c, they simply need to create those two _index.md that I show below with the † sign, right?

Yes. Which is kind of "manual" and not automatic... But I think less magical and certainly more flexible.

Your table is almost spot on.: No, because they don't have any "_index.*" file

@bep
Copy link
Member Author

bep commented Aug 6, 2019

Ref. the discussion above, and esp. @kaushalmodi 's table: Does this change make sense? If you see some unforeseen consequences, please explain below.


@bep
Copy link
Member Author

bep commented Aug 13, 2019

This was fixed in 7ff0a8e

@bep bep closed this as completed Aug 13, 2019
Roboe added a commit to Roboe/blog that referenced this issue Sep 28, 2019
Changelog for v0.57.0: https://github.com/gohugoio/hugo/releases/tag/v0.57.0

> `home.Pages` now only returns pages in the top level section. Before this release, it included _all regular pages in the site_. This made it easy to list all the pages on home page, but it also meant that you needed to take special care if you wanted to navigate the page tree from top to bottom. If you need _all regular pages_, use `.Site.RegularPages`. Also see gohugoio/hugo#6153.
> `.Pages` now include sections. We have added `.RegularPages` as a convenience method if you want the old behaviour. See gohugoio/hugo#6171 for details.
@github-actions
Copy link

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 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants