Skip to content

Missing Trailing Slash

The missing trailing slash error indicates that a link points to an existing page, but the link is missing the trailing slash required by Astro’s trailingSlash option when it is set to 'always'. If your site uses trailingSlash: 'always', /guides/usage should be written as /guides/usage/.

For example, given the following project structure:

  • Directorysrc/
    • Directorycontent/
      • Directorydocs/
        • Directoryguides/
          • installation.md
          • usage.mdx
        • getting-started.md
  • astro.config.mjs

With the following configuration in astro.config.mjs:

astro.config.mjs
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import starlightLinksValidator from 'starlight-links-validator'
export default defineConfig({
integrations: [
starlight({
plugins: [starlightLinksValidator()],
title: 'My Docs',
}),
],
trailingSlash: 'always',
})

And the following content in src/content/docs/getting-started.md:

src/content/docs/getting-started.md
---
title: Getting Started
---
## Next Steps
- [Usage guide](/guides/usage)
- [Installation guide](/guides/installation/)

Running a production build reports the following error:

astro build
╭─ getting-started.md
·
7 | /guides/usage
· ╰── missing trailing slash
╭─ ─╮
· Found 1 invalid link in 1 file. ·
╰─ ─╯

To fix missing trailing slash errors, update each affected link so it matches the trailing slash style required by your Astro configuration.

For this example:

  • Update /guides/usage to /guides/usage/.