Skip to content

feat: add nested section hierarchy and breadcrumbs - #2457

Merged
ArnaudLigny merged 4 commits into
masterfrom
nested-sections-2026
Aug 25, 2026
Merged

feat: add nested section hierarchy and breadcrumbs#2457
ArnaudLigny merged 4 commits into
masterfrom
nested-sections-2026

Conversation

@ArnaudLigny

@ArnaudLigny ArnaudLigny commented Aug 25, 2026

Copy link
Copy Markdown
Member

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:

  • Added sub-section support: Any nested folder with an index.md file 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.
  • New template variables: Introduced page.parent, page.ancestors, page.sections, and page.toplevel for use in templates, enabling breadcrumb trails, sub-section menus, and top-level section navigation.
  • Breadcrumb navigation: Added a ready-to-use partials/breadcrumb.html.twig partial and included it by default in the page layout for improved navigation.
  • Documentation updates: Expanded both English and French documentation to explain sub-sections, new template variables, and navigation patterns with code examples.
  • Layout and style improvements: Adjusted main content width and header layout for better display, especially with the new breadcrumb 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.

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.
@ArnaudLigny
ArnaudLigny marked this pull request as ready for review August 25, 2026 14:16
Copilot AI lite review requested due to automatic review settings August 25, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Section and Homepage generators.
  • Added Page APIs (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 under src/.
                    $toplevel = !str_contains($path, '/');

src/Generator/Section.php:153

  • These newly introduced native function calls should be prefixed with \\ to match the established style under src/.
                    while (($pos = strrpos($parentPath, '/')) !== false) {
                        $parentPath = substr($parentPath, 0, $pos);

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Generator/Section.php
Comment thread src/Generator/Section.php
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());
Comment thread resources/layouts/_default/page.html.twig Outdated
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.
@ArnaudLigny
ArnaudLigny merged commit 8569a0f into master Aug 25, 2026
20 checks passed
@ArnaudLigny
ArnaudLigny deleted the nested-sections-2026 branch August 25, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants