This Astro integration, currently at version 0.4.2, automatically converts absolute and `base`-relative paths within an Astro project to truly relative links during the build process. It addresses a common need for static sites that might be deployed to subdirectories or file systems where absolute paths can break. The project maintains a fairly active release cadence, providing fixes for bugs (e.g., Windows path issues, URL pathname spaces) and adding support for various HTML elements (like `video` poster, embedded styles) and other Astro ecosystem tools (like `astro-compress`, `astro-islands`). Its key differentiator is simplifying deployment flexibility for Astro sites by ensuring all assets, links, and resources are referenced relatively, eliminating the need for complex `base` path handling at runtime. It requires Astro version 3.0.0 or higher.
npm install astro-relative-linksVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and register the `astro-relative-links` integration in `astro.config.mjs` to enable relative path generation for all build outputs.
Upgrade your Astro project to version 3.0.0 or higher, or use an older version of `astro-relative-links` (e.g., <0.4.2) compatible with your Astro version.
Upgrade to version 0.3.5 or newer to ensure correct handling of paths with spaces.
Upgrade to version 0.3.2 or newer for improved Windows compatibility and reliable path handling.
Upgrade to version 0.4.0 or newer for full support of URL processing within embedded `<style>` tags.
Ensure you are using the correct ESM default import: `import relativeLinks from 'astro-relative-links';`
Run `npm install astro-relative-links` or `pnpm install astro-relative-links` or `yarn add astro-relative-links` to install the package.
Upgrade Astro to version 3.0.0 or later: `npm install astro@latest` or `pnpm update astro` or `yarn upgrade astro`.