From 72483c4ec5141277007c531a6003b7d96cd0d1d1 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sat, 6 Sep 2025 18:36:47 -0400 Subject: [PATCH] feat(seo): add canonical, OG/Twitter, hreflang per-page, JSON-LD; set site; add robots.txt --- astro.config.mjs | 1 + public/robots.txt | 4 ++++ src/layouts/BaseLayout.astro | 40 ++++++++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 public/robots.txt diff --git a/astro.config.mjs b/astro.config.mjs index 1405559..b34e837 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,6 +5,7 @@ import tailwindcss from "@tailwindcss/vite"; // https://astro.build/config export default defineConfig({ + site: "https://villafleuriegp.com", i18n: { locales: ["fr", "en"], defaultLocale: "fr", diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..b4b623b --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Allow: / + +Sitemap: https://villafleuriegp.com/sitemap.xml diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index b73789a..3550788 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -3,8 +3,11 @@ import '../styles/global.css'; import { ctaLabelFor } from '../i18n/routes'; import { getRelativeLocaleUrl } from 'astro:i18n'; const { title = 'VillaFleurie', lang = 'fr', description = 'Séjours confortables au Gosier pour couples et petites familles' } = Astro.props; -const altFr = "/fr/"; -const altEn = "/en/"; +// Locale alternates for the current path +const altFr = getRelativeLocaleUrl('fr', Astro.url.pathname); +const altEn = getRelativeLocaleUrl('en', Astro.url.pathname); +// Canonical URL +const canonicalUrl = new URL(Astro.url.pathname, Astro.site ?? 'https://villafleuriegp.com').toString(); const nav = lang === 'en' ? [ { label: 'Apartments', href: getRelativeLocaleUrl('en', '/apartments/') }, @@ -28,10 +31,25 @@ const homeHref = getRelativeLocaleUrl(lang, '/'); {title} · VillaFleurie + + + + + + + + + + + + + + +
@@ -121,5 +139,23 @@ const homeHref = getRelativeLocaleUrl(lang, '/'); } +