My website’s root page is on a subdirectory like so: mywebsite.com - This website is for sale! - mywebsite Resources and Information..
I am using Astro to build this website. Locally, everything works as expected. The canonical of the home page is like it should be. However, when I trigger the branch build on Netlify, my website has a canonical link with “/2025” stripped away from the base URL.
Here is my astro.config.mjs:
import {defineConfig} from ‘astro/config’;
import sitemap from ‘@astrojs/sitemap’;
import tailwind from “@astrojs/tailwind”;
import netlify from “@astrojs/netlify”;
import react from “@astrojs/react”;
import partytown from “@astrojs/partytown”;
// https://astro.build/config
export default defineConfig({
integrations: [sitemap(), tailwind(), react(), partytown()],
output: “server”,
adapter: netlify(),
image: {
domains: [“v5.airtableusercontent.com”]
},
base: “/2025”,
site: “https://mywebsite.com”,
});
Canonical link is built like this:
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
How can I force the canonical to be exactly “mywebsite.com - This website is for sale! - mywebsite Resources and Information.” without messing up the dynamics of building other canonical link for other pages?