Skip to content

Comments

[BUGFIX] Exclude orphan pages from next/prev navigation#1138

Merged
linawolf merged 2 commits intoTYPO3-Documentation:mainfrom
CybotTM:fix/exclude-orphans-from-navigation
Dec 30, 2025
Merged

[BUGFIX] Exclude orphan pages from next/prev navigation#1138
linawolf merged 2 commits intoTYPO3-Documentation:mainfrom
CybotTM:fix/exclude-orphans-from-navigation

Conversation

@CybotTM
Copy link
Contributor

@CybotTM CybotTM commented Dec 22, 2025

Summary

This PR fixes the issue where orphan pages (marked with :orphan: directive) are incorrectly included in the next/previous navigation chain, causing broken navigation links.

Resolves: #1137

Changes

Core Fix (TwigExtension.php)

  • Added isOrphanDocument() helper method to detect if a document entry corresponds to an orphan page
  • Modified getPagerLinks() to:
    • Return only the "top" link for orphan pages (no prev/next)
    • Exclude orphan targets from prev/next links
  • Modified getPrevNextLinks() to:
    • Return empty array for orphan pages
    • Exclude orphan targets from the navigation links

Test Updates

Updated expected output files to reflect the corrected behavior:

  • next-prev-by-toctree/expected/i.html - orphan page no longer has prev/next links
  • next-prev-by-toctree/expected/three/pi.html - orphan page no longer has prev/next links
  • next-prev-by-toctree/expected/four.html - no longer links to orphan i.html
  • changelog/expected/Index.html - no longer links to orphan Changelog-12.html
  • changelog/expected/Changelog/12.0/Index.html - no longer has prev link to orphan
  • main-menu-json/expected/index.html - no longer links to orphan mainMenu.json.html

Test Plan

  • vendor/bin/phpunit --filter next-prev-by-toctree passes
  • vendor/bin/phpunit tests/Integration/IntegrationTest.php passes (108 tests, all assertions pass)
  • PHP syntax check passes

Before/After

Before: Clicking "Next" on docs.typo3.org/Home/Overview.html leads to WikiLanding.html → mainMenu.json.html (404)

After: Orphan pages are excluded from navigation chain, preventing broken links

Orphan pages marked with :orphan: directive should not appear in
next/previous navigation links. This fixes the issue where:

- Normal pages had "Next" links pointing to orphan pages
- Orphan pages like mainMenu.json.rst were included in navigation
  sequence, causing 404 errors when navigating

The fix adds a helper method isOrphanDocument() and modifies
getPagerLinks() and getPrevNextLinks() to:
1. Not show next/prev links on orphan pages
2. Not include orphan pages as next/prev targets

Resolves: TYPO3-Documentation#1137
@linawolf
Copy link
Member

Let us merge this for now and test it out

@linawolf linawolf merged commit de2dd77 into TYPO3-Documentation:main Dec 30, 2025
8 checks passed
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.

Orphan pages incorrectly included in next/prev navigation

2 participants