mirror of
https://github.com/rjNemo/vf-site
synced 2026-06-12 12:06:39 +00:00
fix(seo): correct hreflang alternates by stripping locale prefix; set x-default to default locale page
This commit is contained in:
parent
72483c4ec5
commit
492b549d8b
5 changed files with 1146 additions and 2268 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
import { defineConfig } from "astro/config";
|
import { defineConfig } from "astro/config";
|
||||||
|
import sitemap from "@astrojs/sitemap";
|
||||||
|
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
|
||||||
|
|
@ -14,6 +15,7 @@ export default defineConfig({
|
||||||
redirectToDefaultLocale: true,
|
redirectToDefaultLocale: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
integrations: [sitemap()],
|
||||||
vite: {
|
vite: {
|
||||||
plugins: [tailwindcss()],
|
plugins: [tailwindcss()],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"format": "prettier -wl ."
|
"format": "prettier -wl ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@astrojs/sitemap": "^3.1.0",
|
||||||
"@tailwindcss/vite": "^4.1.13",
|
"@tailwindcss/vite": "^4.1.13",
|
||||||
"astro": "^5.13.5",
|
"astro": "^5.13.5",
|
||||||
"lucide-astro": "^0.542.0",
|
"lucide-astro": "^0.542.0",
|
||||||
|
|
|
||||||
3396
pnpm-lock.yaml
3396
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,6 @@
|
||||||
User-agent: *
|
User-agent: *
|
||||||
Allow: /
|
Allow: /
|
||||||
|
|
||||||
|
# Both standard and index sitemaps (plugin may generate an index)
|
||||||
Sitemap: https://villafleuriegp.com/sitemap.xml
|
Sitemap: https://villafleuriegp.com/sitemap.xml
|
||||||
|
Sitemap: https://villafleuriegp.com/sitemap-index.xml
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,14 @@ import '../styles/global.css';
|
||||||
import { ctaLabelFor } from '../i18n/routes';
|
import { ctaLabelFor } from '../i18n/routes';
|
||||||
import { getRelativeLocaleUrl } from 'astro:i18n';
|
import { getRelativeLocaleUrl } from 'astro:i18n';
|
||||||
const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortables au Gosier pour couples et petites familles' } = Astro.props;
|
const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortables au Gosier pour couples et petites familles' } = Astro.props;
|
||||||
// Locale alternates for the current path
|
// Locale alternates: strip current locale prefix before generating sibling paths
|
||||||
const altFr = getRelativeLocaleUrl('fr', Astro.url.pathname);
|
const pathSuffix = (() => {
|
||||||
const altEn = getRelativeLocaleUrl('en', Astro.url.pathname);
|
const p = Astro.url.pathname;
|
||||||
|
const stripped = p.replace(/^\/(fr|en)/, "");
|
||||||
|
return stripped === "" ? "/" : stripped;
|
||||||
|
})();
|
||||||
|
const altFr = getRelativeLocaleUrl('fr', pathSuffix);
|
||||||
|
const altEn = getRelativeLocaleUrl('en', pathSuffix);
|
||||||
// Canonical URL
|
// Canonical URL
|
||||||
const canonicalUrl = new URL(Astro.url.pathname, Astro.site ?? 'https://villafleuriegp.com').toString();
|
const canonicalUrl = new URL(Astro.url.pathname, Astro.site ?? 'https://villafleuriegp.com').toString();
|
||||||
const nav = lang === 'en'
|
const nav = lang === 'en'
|
||||||
|
|
@ -35,7 +40,7 @@ const homeHref = getRelativeLocaleUrl(lang, '/');
|
||||||
<link rel="icon" href="/assets/images/logo.png" />
|
<link rel="icon" href="/assets/images/logo.png" />
|
||||||
<link rel="alternate" hreflang="fr" href={altFr} />
|
<link rel="alternate" hreflang="fr" href={altFr} />
|
||||||
<link rel="alternate" hreflang="en" href={altEn} />
|
<link rel="alternate" hreflang="en" href={altEn} />
|
||||||
<link rel="alternate" hreflang="x-default" href="/fr/" />
|
<link rel="alternate" hreflang="x-default" href={altFr} />
|
||||||
<!-- Open Graph -->
|
<!-- Open Graph -->
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:site_name" content="VillaFleurie" />
|
<meta property="og:site_name" content="VillaFleurie" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue