|
| 1 | +--- |
| 2 | + |
| 3 | +# ADR 0008 — URL structure: MyST flat slugs vs Hugo hierarchical paths |
| 4 | + |
| 5 | +Date: 2026-05-19 |
| 6 | +Status: Proposed |
| 7 | +Branch: lb/myst-migration |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +Hugo derives page URLs from the directory structure: `content/about/governance.md` |
| 12 | +→ `/about/governance/`. The directory hierarchy IS the URL. |
| 13 | + |
| 14 | +MyST derives URLs from the filename only, ignoring the containing directory: |
| 15 | +`content/about/governance.md` → `/governance`. Files named `index.md` in |
| 16 | +subdirectories collide on the slug `index` and are deduplicated as `index-1`, |
| 17 | +`index-2`, etc.: `content/about/index.md` → `/index-1`. |
| 18 | + |
| 19 | +This behaviour is not user-configurable; URL generation is internal to MyST. |
| 20 | + |
| 21 | +This was surfaced by `netlify-plugin-checklinks` during the first Netlify |
| 22 | +deploy of the PR. The build succeeds; the link checker finds broken internal |
| 23 | +links because content was authored for Hugo-style hierarchical URLs |
| 24 | +(`/about/governance`, `/contributors/`, etc.) that no longer exist in the |
| 25 | +MyST output. |
| 26 | + |
| 27 | +Affected link types: |
| 28 | + |
| 29 | +- Section index cards: `:link: /contributors/`, `:link: /documentation/` etc. |
| 30 | + in `content/index.md` |
| 31 | +- Inline markdown links: `[Role](/community/role)` in `content/community/index.md` |
| 32 | +- Sidebar navigation links generated by MyST from the toc (use actual slugs, |
| 33 | + so these are self-consistent but don't match the Hugo URL shape) |
| 34 | + |
| 35 | +## Options considered |
| 36 | + |
| 37 | +1. **Rename `index.md` to `section.md` + update all internal links to flat URLs** |
| 38 | + - Rename each `content/<section>/index.md` to `content/<section>/<section>.md` |
| 39 | + so MyST generates slug `/<section>` instead of `/index-N`. |
| 40 | + - Update all cross-page links in content to use flat URLs (`/governance` |
| 41 | + not `/about/governance`). |
| 42 | + - Add a Netlify `_redirects` file mapping old Hugo URLs to new flat URLs for |
| 43 | + external link / bookmark compatibility. |
| 44 | + - Pros: honest fix, works within MyST's model, flat URLs are simpler. |
| 45 | + - Cons: URL structure changes permanently; external links to the Hugo site |
| 46 | + break without redirects; flat URLs lose the section context for users |
| 47 | + reading the URL. |
| 48 | + |
| 49 | +2. **Netlify `_redirects` shim (keep Hugo-style links, redirect to flat URLs)** |
| 50 | + - Keep content links as-is; add a `_redirects` file that maps every |
| 51 | + hierarchical Hugo URL to the corresponding flat MyST slug. |
| 52 | + - Pros: no content changes; external links preserved. |
| 53 | + - Cons: fragile — `index-N` numbering shifts if toc order changes; |
| 54 | + maintenance burden every time a page is added; masks the underlying issue. |
| 55 | + |
| 56 | +3. **Disable `netlify-plugin-checklinks` failure / warn-only** |
| 57 | + - Configure or remove the plugin so broken links produce warnings, not a |
| 58 | + build failure. Defers URL fix to a follow-up issue. |
| 59 | + - Pros: unblocks the PR immediately. |
| 60 | + - Cons: leaves broken links in the deployed site; removes the safety net. |
| 61 | + |
| 62 | +4. **File a MyST feature request for directory-based URL generation** |
| 63 | + - Request that MyST support an option to derive page URLs from the directory |
| 64 | + path rather than the filename alone. |
| 65 | + - Pros: correct fix at the right layer; no workarounds needed. |
| 66 | + - Cons: timeline unknown; blocks the PR on upstream response. |
| 67 | + |
| 68 | +## Decision |
| 69 | + |
| 70 | +_Pending team discussion._ |
| 71 | + |
| 72 | +## Consequences |
| 73 | + |
| 74 | +- Until resolved, `netlify-plugin-checklinks` will fail on every Netlify deploy. |
| 75 | +- Option 1 (rename + redirects) is the most honest long-term fix and aligns with |
| 76 | + MyST's design; it should be the default choice unless a MyST fix lands quickly. |
| 77 | +- This ADR should be inserted before the Phase 3 commits in the final commit |
| 78 | + history, since the URL structure decision affects how shortcode links are |
| 79 | + written. |
| 80 | +- If option 1 is chosen, Phase 3 (shortcode conversion) commits will need a |
| 81 | + follow-up fixup to update card `:link:` values and inline markdown links. |
0 commit comments