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.

Brainstorming

Redirects

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 β†—.

Bare slugs

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:

Hack for Starlight

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 β†—

Permanent Anchors

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}

Conflicting Pages

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.