Skip to content

Local Link

The local link error indicates that a link uses a local development URL, such as a URL with the localhost or 127.0.0.1 hostname.

Local links are usually intended only for development and should not be present in production content. If you prefer to ignore local links instead of erroring on them, you can disable this error using the errorOnLocalLinks option.

For example, given the following project structure:

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

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

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

Running a production build reports the following errors:

astro build
╭─ getting-started.md
·
7 | http://localhost:4321/guides/installation/
· ╰── local link
8 | https://127.0.0.1:4321/guides/usage/
· ╰── local link
╭─ ─╮
· Found 2 invalid links in 1 file. ·
╰─ ─╯

To fix local link errors, replace each local development URL with the correct production URL or root-relative path.

For this example:

  • Update http://localhost:4321/guides/installation/ to /guides/installation/.
  • Update https://127.0.0.1:4321/guides/usage/ to /guides/usage/.