Skip to content

Permanent links

Problem: Links in Starlight (and autogenerated sidebar) are connected to the file path. However, in digital gardens, content often gets moved around, resulting in broken links.

Every time a page is moved, add the previous version to the redirects ↗ section.

It would be even better if these redirects could be specified in the frontmatter ↗, similar to how it’s done in Hugo ↗.

For example, if the path is some/thing/a.md, generate the URL as /a instead of some/thing/a. This allows you to move the file to other/a.md without changing the URL.

Paths can be used for:

This behavior can be achieved in Starlight by putting slug in the frontmatter:

src/content/docs/recipes/alphabetical-index.mdx
---
slug: alphabetical-index
---

Related: starlight#2052 ↗

Anchors can also break, though this issue is likely less significant compared to broken links.

One approach is to specify an ID instead of using a slug ↗. This allows you to change the heading text without altering the ID:

### My Great Heading {#custom-id}

In addition to content pages, there will be some special pages, such as:

  • /recent
    • /recent/[page]
  • /graph
  • /alphabetical
  • /tags
    • /tags/[name]
  • /search
  • etc.

In these cases, built-in pages should take priority over content pages, which may require renaming some content pages. However, for /tags/[name], both content and built-in pages can be displayed, similar to how it’s handled in Hugo.