-
Notifications
You must be signed in to change notification settings - Fork 7
Document slug auto-generation for all navigation items #5736
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
Merged
+96
−68
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
634bdb2
Add comprehensive slug documentation to navigation page
fern-api[bot] a0c85ab
Reconcile slug docs: trim navigation page, add algorithm to canonical…
fern-api[bot] 27964bd
Expand frontmatter slug override explanation on canonical slug page
fern-api[bot] db1600a
Trim navigation page slug section to brief explanation + link to cano…
fern-api[bot] b840f93
update intro
devalog 6aed8e4
Correct frontmatter slug docs: preserves product/version prefixes, do…
fern-api[bot] 5d965d8
Merge branch 'fern/document-slug-generation' of https://github.com/fe…
devalog 8c6a807
clarify wording and structure
devalog f88cfde
Merge branch 'main' into fern/document-slug-generation
devalog c13e29f
fix parse error
devalog 172baa9
fix render error
devalog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,20 @@ | ||
| --- | ||
| title: Customizing slugs within your site | ||
| title: Configuring slugs | ||
| description: Customize URL paths in your Fern documentation site. Rename slugs for pages, sections, tabs, landing pages, and subheadings, or skip them entirely. | ||
| --- | ||
|
|
||
| By default, Fern generates the slug of a page based on the navigation structure in the `docs.yml` file. Each navigation item — sections, pages, tabs, versions, and products — gets a slug derived from its display name by lowercasing and replacing spaces with hyphens. Special characters such as parentheses are stripped. | ||
|
|
||
| By default, Fern generates the slug of a page based on the navigation structure in the `docs.yml` file. | ||
| For [folder-based navigation](/learn/docs/configuration/navigation#add-a-folder), page slugs are derived from filenames rather than display names. | ||
|
|
||
| | Navigation item | Slug derived from | Example | Auto-generated slug | | ||
| |---|---|---|---| | ||
| | Section | `section` name | `Key Concepts` | `key-concepts` | | ||
| | Page | `page` name | `Quick Start` | `quick-start` | | ||
| | Folder | Directory name or `title` | `api-guides` | `api-guides` | | ||
| | Tab | `display-name` | `API Reference` | `api-reference` | | ||
| | Version | `display-name` | `v3 (Latest)` | `v-3-latest` | | ||
| | Product | `display-name` | `My Product` | `my-product` | | ||
|
|
||
| <AccordionGroup> | ||
| <Accordion title="Example without tabs" defaultOpen> | ||
|
|
@@ -56,7 +66,7 @@ You can customize these default slugs by renaming them or skipping them entirely | |
| Set the `slug` property in `docs.yml` or in a page's frontmatter to customize the URL path. | ||
|
|
||
| ### Modify a page or section slug | ||
| To modify the slug used for a page or section, you can set the `slug` within the `navigation` object. | ||
| To modify the slug used for a page or section, set the `slug` within the `navigation` object. | ||
|
|
||
| ```yaml docs.yml {3, 6} | ||
| navigation: | ||
|
|
@@ -72,7 +82,7 @@ In the example above, the **Welcome** page would be hosted at `plantstore.docs.b | |
|
|
||
| ### Modify a tab slug | ||
|
|
||
| To modify the slug used for a tab, you can set the `slug` within the `tabs` object. | ||
| To modify the slug used for a tab, set the `slug` within the `tabs` object. | ||
|
|
||
| ```yaml docs.yml {4} | ||
| tabs: | ||
|
|
@@ -94,40 +104,16 @@ navigation: | |
| In the example above, the **Welcome** page would be hosted at `plantstore.docs.buildwithfern.com/guides/get-started/welcome`. | ||
|
|
||
| ### Modify a landing page's slug | ||
| To modify the slug used for a landing page, you can set the `slug` within the `landing-page` object. | ||
| To modify the slug used for a landing page, set the `slug` within the `landing-page` object. | ||
|
|
||
| ```yaml title="docs.yml" {4} | ||
| landing-page: | ||
| page: Page Title | ||
| path: path/to/landing-page.mdx | ||
| slug: /welcome | ||
| ``` | ||
| ### Rename subheading slugs | ||
|
|
||
| ### Override a page's slug with frontmatter | ||
|
|
||
| Frontmatter slugs take precedence over slugs generated or set in `docs.yml`, giving you full control over a page's URL. | ||
|
|
||
| ```yaml title="docs.yml" | ||
| navigation: | ||
| - section: Get Started | ||
| slug: start | ||
| contents: | ||
| - page: Quickstart | ||
| path: ./docs/pages/quickstart.mdx | ||
| ``` | ||
|
|
||
| With this configuration, the page would normally be at `plantstore.docs.buildwithfern.com/start/quickstart`. To override this, set `slug` in the page's frontmatter: | ||
|
|
||
| ```markdown title="quickstart.mdx" {2} | ||
| --- | ||
| title: Quickstart | ||
| slug: start-up | ||
| --- | ||
| ``` | ||
|
|
||
| The page is now available at `plantstore.docs.buildwithfern.com/start/start-up` instead. See [frontmatter configuration](/learn/docs/configuration/page-level-settings#slug) for more details. | ||
|
|
||
| ### Renaming slugs for subheadings | ||
| By default, deep links to subheadings are generated by appending a `#` and the subheading title (converted to `kebab-casing-convention`) onto the page URL. | ||
|
|
||
| ```yaml docs.yml | ||
|
|
@@ -138,7 +124,7 @@ navigation: | |
| path: ./docs/pages/welcome.mdx | ||
| ``` | ||
|
|
||
| ```markdown welcome.mdx | ||
| ```jsx welcome.mdx | ||
| ... | ||
|
|
||
| ## Frequently Asked Questions | ||
|
|
@@ -149,12 +135,65 @@ The link to this section will be available at `plantstore.docs.buildwithfern.com | |
|
|
||
| To rename the slug of the subheading, add the desired slug: | ||
|
|
||
| ```markdown welcome.mdx | ||
| ```jsx welcome.mdx | ||
| ## Frequently Asked Questions [#faqs] | ||
| ``` | ||
|
|
||
| The link to this section will now be available at `plantstore.docs.buildwithfern.com/get-started/welcome#faqs`. | ||
|
|
||
| ### Override with a frontmatter slug | ||
|
|
||
| A `slug` set in `docs.yml` replaces only that item's segment, preserving the parent hierarchy. A `slug` set in page frontmatter replaces the **section and folder hierarchy** for that page, but preserves any product or version prefix. | ||
|
|
||
| Use frontmatter `slug` when a page needs a short, memorable URL independent of its sidebar position (e.g., a top-level quickstart, a campaign landing page, or a page that moved but must keep its old URL). | ||
|
|
||
| ```yaml title="docs.yml" {3, 6} | ||
| navigation: | ||
| - section: Get Started | ||
| slug: start | ||
| contents: | ||
| - page: Quickstart | ||
| slug: quick | ||
| path: ./docs/pages/quickstart.mdx | ||
| ``` | ||
|
|
||
| With only `docs.yml` slugs, the page URL is `plantstore.docs.buildwithfern.com/start/quick` — the hierarchy is preserved. To replace that hierarchy and set the page's path directly, set `slug` in the page's frontmatter: | ||
|
|
||
| ```markdown title="quickstart.mdx" | ||
| --- | ||
| slug: quickstart | ||
| --- | ||
| ``` | ||
|
|
||
| The page is now at `plantstore.docs.buildwithfern.com/quickstart`, bypassing the section hierarchy. The page still appears in the sidebar under "Get Started", but its URL no longer reflects that structure. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| #### Behavior with products and versions | ||
|
|
||
| When a page lives inside a [product](/learn/docs/configuration/navigation#add-a-product) or [version](/learn/docs/configuration/navigation#add-a-version), setting a frontmatter slug replaces only the section/folder portion of the URL. The product and version slugs are always preserved. | ||
|
|
||
| ```yaml title="docs.yml" | ||
| products: | ||
| - display-name: Platform | ||
| slug: platform | ||
| navigation: | ||
| - tab: guides | ||
| layout: | ||
| - section: Get Started | ||
| contents: | ||
| - page: Quickstart | ||
| path: ./docs/pages/quickstart.mdx | ||
| ``` | ||
|
|
||
| ```markdown title="quickstart.mdx" | ||
| --- | ||
| slug: quickstart | ||
| --- | ||
| ``` | ||
|
|
||
| The resulting URL is `plantstore.docs.buildwithfern.com/platform/quickstart` — **not** `/quickstart`. The product slug `platform` is retained; only the section and tab hierarchy is bypassed. | ||
|
|
||
| The same applies to versions: a page in version "v2" of product "platform" with frontmatter `slug: quickstart` resolves to `/platform/v2/quickstart`. To move a page to the absolute root of your docs, place it outside any product or version in your navigation structure. | ||
|
|
||
| ## Skipping slugs | ||
| To ignore a tab or section when generating the slug, simply indicate `skip-slug: true`. | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Headings] 'Slugs and URL paths' should use sentence-style capitalization.