feat: add nested section hierarchy and breadcrumbs - #2457
Merged
Conversation
Implement explicit nested section support from folder `index.md` files, including parent/ancestor relationships, immediate child sections, and top-level section flags. Update section/homepage generation to expose this structure for navigation, add a reusable Twig breadcrumb partial to the default page layout, document the new page variables and subsection behavior (EN/FR), and add unit tests for page and section hierarchy behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for nested sections (sub-sections) in Cecil’s content model and generators, and exposes new navigation-oriented page variables intended for breadcrumbs and section menus. It also updates the default theme to include breadcrumbs and expands the docs (EN/FR) with examples.
Changes:
- Implemented nested section generation and parent/ancestor/child-section tracking in
SectionandHomepagegenerators. - Added
PageAPIs (isSectionIndex(),getParent(),getAncestors(),getSections()) and unit tests covering the new hierarchy behavior. - Added a breadcrumb Twig partial, included it in the default page layout, and updated docs to document the new template variables and patterns.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Generator/SectionTest.php | Adds unit coverage for sub-section creation, membership, hierarchy (parent/ancestors), and menu/top-level behavior. |
| tests/Unit/Collection/Page/PageTest.php | Adds unit coverage for Page::isSectionIndex() behavior across folder index, nested index, normal page, and homepage. |
| src/Generator/Section.php | Implements sub-section detection, multi-section membership (root + ancestor sub-sections), and sets parent, sections, and toplevel variables. |
| src/Generator/Homepage.php | Populates homepage sections with top-level section pages for main navigation use. |
| src/Collection/Page/Page.php | Adds section-index detection and exposes hierarchy helpers (getParent(), getAncestors(), getSections()). |
| resources/layouts/partials/breadcrumb.html.twig | Introduces a reusable breadcrumb partial based on page.ancestors. |
| resources/layouts/_default/page.html.twig | Adjusts layout/CSS and includes breadcrumbs by default in the main content area. |
| docs/3-Templates.md | Documents page.parent, page.ancestors, page.sections, page.toplevel and provides navigation examples. |
| docs/3-Templates.fr.md | French equivalent of the templates documentation updates. |
| docs/2-Content.md | Documents “Sub-section” behavior and folder structure expectations. |
| docs/2-Content.fr.md | French equivalent of the content documentation updates. |
| composer.lock | Updates locked dependency versions. |
Suppressed comments (2)
src/Generator/Section.php:130
- This new
str_contains()call should be prefixed with\\to match the PHP style used elsewhere undersrc/.
$toplevel = !str_contains($path, '/');
src/Generator/Section.php:153
- These newly introduced native function calls should be prefixed with
\\to match the established style undersrc/.
while (($pos = strrpos($parentPath, '/')) !== false) {
$parentPath = substr($parentPath, 0, $pos);
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+71
to
+75
| // a sub-section index page is not listed in its parent section(s) | ||
| if ($page->isSectionIndex() && isset($subSections[(string) $page->getPath()])) { | ||
| continue; | ||
| } | ||
| $language = $page->getVariable('language', $this->config->getLanguageDefault()); |
Refreshes generated phpDocumentor output under `docs/api` to match recent source updates. The docs now expose new `Page` section-navigation APIs (`isSectionIndex`, `getParent`, `getAncestors`, `getSections`) and `$sectionIndex`, update Section generator documentation for nested sub-sections, and reflect type/signature updates like `Image::manager()` returning `ImageManagerInterface`. Search index and deprecated report line mappings were updated accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces full support for nested sections (sub-sections) in the content structure, along with new template variables and navigation helpers to improve content organization and navigation. The documentation and templates are updated to explain and demonstrate these new features, and several code changes implement the underlying logic for sub-sections, parent/ancestor section tracking, and main navigation improvements.
Support for nested sections and navigation enhancements:
index.mdfile is now treated as a sub-section, with pages belonging to both their immediate sub-section and all ancestor sections. Sub-section index pages are not listed in their parent section.page.parent,page.ancestors,page.sections, andpage.toplevelfor use in templates, enabling breadcrumb trails, sub-section menus, and top-level section navigation.partials/breadcrumb.html.twigpartial and included it by default in the page layout for improved navigation.These changes make it easier to organize large sites with deeply nested content, and provide out-of-the-box navigation helpers for complex section hierarchies.