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

Feature: Generate navigation hierarchy from page urls #1588

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

pdmosses
Copy link
Contributor

@pdmosses pdmosses commented Jan 2, 2025

Close #1570

Add the configuration option nav_urls and the page option nav_fold to multi-level navigation.

Configuration option nav_urls

When nav_urls == true:

  • generate a multi-level navigation hierarchy from the page urls
  • ignore page front matter fields parent, grand_parent, ancestor

The navigation hierarchy is unaffected by adding the configuration option permalink: pretty.

Note

Each url level with child pages requires a parent page in the main navigation.

Front matter option nav_fold

By default, top-level pages with child pages are initially displayed folded. For collections, there is an option nav_fold with default value true: when false, the top level of the collection navigation is unfolded to display links to the top-level pages in the collection. Now, when nav_fold: false is added in the front matter of a parent page, it is initially displayed unfolded.

Most pages on the theme website have urls of the form /docs/*. The parent page for that level is added at /docs/index.md; it could alternatively be added at /docs.md. To ensure that links to the top-level pages in the docs folder are visible on the theme home page, the added parent page front matter includes nav_fold: false.

(The existing theme docs pages have not yet been updated to explain the configuration and use of the nav_urls option.)

Acknowledgment

The implementation of this feature is based on the modifications of just-the-docs@v0.5.0 reported by @EricFromCanada in discussion #583.

Testing

To test this PR, use theme: just-the-docs in _config.yml and the following in your Gemfile:

gem "just-the-docs", github: "pdmosses/just-the-docs", branch: "nav-urls"

Preliminary local testing includes the Just the Docs theme website and the Just the Docs Tests website, as well as the company manual website referenced in #583.1

Warning

This PR has not yet been throughly tested or reviewed, and may change!

Footnotes

  1. The pages of the company manual website are pure Markdown, with no front matter markup at all. Various (safe) Jekyll plugins allow the omission of the page title and layout fields.

Add configuration option `nav_urls`.

When `site.nav_urls == true`:
- generate navigation hierarchy from page urls
- each url level with children needs an parent page
- ignore page front matter `parent`, `grand_parent`, `ancestor`

When `page.nav_fold == false`:
- display links to child pages in navigation
Add `nav_urls: true` in configuration.

Add `/docs/index.md` page with `nav_fold: false`
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.

Feature request: Automatically generate navigation structure based on directory structure
1 participant