
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
astro-relative-links
Advanced tools
This Astro integration builds Astro with relative links.
The astro add command-line tool automates the installation for you. Run one of the following commands in a new terminal window. (If you aren't sure which package manager you're using, run the first command.) Then, follow the prompts, and type "y" in the terminal (meaning "yes") for each one.
# Using NPM
npx astro add astro-relative-links
# Using Yarn
yarn astro add astro-relative-links
# Using PNPM
pnpm astro add astro-relative-links
If you run into any issues, feel free to report them to me on GitHub and try the manual installation steps below.
First, install the astro-relative-links packages using your package manager. If you're using npm or aren't sure, run this in the terminal:
npm install astro-relative-links
Then, apply this integration to your astro.config.* file using the integrations property:
astro.config.mjs
import { defineConfig } from 'astro/config';
import relativeLinks from 'astro-relative-links';
export default defineConfig({
// ...
integrations: [relativeLinks()],
});
Build as usual with npm run build etc. All links in the project will be generated as relative paths.
dist/index.html
<link rel="stylesheet" href="./_astro/index.*.css" />
<script type="module" src="./_astro/hoisted.*.js"></script>
dist/sub/index.html
<link rel="stylesheet" href="../_astro/index.*.css" />
<script type="module" src="../_astro/hoisted.*.js"></script>
src/components/Header.astro
<a href="/">Home</a>
<a href="/apple/">
<img src="/images/apple.png" alt="" />
Apple
</a>
<a href="/banana/">
<img src="/images/banana.png" alt="" />
Banana
</a>
The above components will be generated as follows.
dist/index.html
<a href="./">Home</a>
<a href="./apple/">
<img src="./images/apple.png" alt="" />
Apple
</a>
<a href="./banana/">
<img src="./images/banana.png" alt="" />
Banana
</a>
dist/apple/index.html
<a href="../">Home</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
dist/banana/index.html
<a href="../">Home</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
base configastro.config.mjs
import { defineConfig } from 'astro/config';
import relativeLinks from 'astro-relative-links';
export default defineConfig({
base: 'fruits',
integrations: [relativeLinks()],
});
src/components/Header.astro
<a href="/">Home</a>
<a href="/fruits/">Fruits</a>
<a href="/fruits/apple/">
<img src="/fruits/images/apple.png" alt="" />
Apple
</a>
<a href="/fruits/banana/">
<img src="/fruits/images/banana.png" alt="" />
Banana
</a>
The above components will be generated as follows.
dist/index.html
<a href="/">Home</a>
<a href="./">Fruits</a>
<a href="./apple/">
<img src="./images/apple.png" alt="" />
Apple
</a>
<a href="./banana/">
<img src="./images/banana.png" alt="" />
Banana
</a>
dist/apple/index.html
<a href="/">Home</a>
<a href="../">Fruits</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
dist/banana/index.html
<a href="/">Home</a>
<a href="../">Fruits</a>
<a href="../apple/">
<img src="../images/apple.png" alt="" />
Apple
</a>
<a href="../banana/">
<img src="../images/banana.png" alt="" />
Banana
</a>
FAQs
Build Astro with relative links.
The npm package astro-relative-links receives a total of 887 weekly downloads. As such, astro-relative-links popularity was classified as not popular.
We found that astro-relative-links demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.