From e0311c3c09cb13b3243b8a9b7b5a4d8e4128d52c Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Tue, 21 Apr 2026 16:39:01 +0200 Subject: [PATCH] fix: replace Astro redirects with static meta-refresh pages for legacy .html URLs GitHub Pages is a static host and does not support server-side redirects. Astro redirects config only works for SSR targets, so legacyHtmlRedirects had no effect. Replace with real .html.astro pages using meta http-equiv=refresh and link rel=canonical. Also disallow legacy URLs in robots.txt. --- site/astro.config.mjs | 12 +----------- site/public/robots.txt | 4 ++++ site/src/pages/alertmanager.html.astro | 16 ++++++++++++++++ site/src/pages/blackbox-exporter.html.astro | 16 ++++++++++++++++ site/src/pages/rules.html.astro | 16 ++++++++++++++++ site/src/pages/sleep-peacefully.html.astro | 16 ++++++++++++++++ 6 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 site/src/pages/alertmanager.html.astro create mode 100644 site/src/pages/blackbox-exporter.html.astro create mode 100644 site/src/pages/rules.html.astro create mode 100644 site/src/pages/sleep-peacefully.html.astro diff --git a/site/astro.config.mjs b/site/astro.config.mjs index 6fcea9f..fc94e64 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -64,20 +64,10 @@ function buildRedirects(base) { const base = '/awesome-prometheus-alerts'; -/** Legacy .html page redirects from the pre-Astro (Jekyll) site. - * These pages 404 after the Astro migration since they moved to trailing-slash directories. - * rules.html alone had 105 referring domains and was the #1 traffic page — critical to preserve. */ -const legacyHtmlRedirects = { - [`${base}/rules.html`]: { destination: `${base}/rules/`, status: 301 }, - [`${base}/alertmanager.html`]: { destination: `${base}/alertmanager/`, status: 301 }, - [`${base}/blackbox-exporter.html`]: { destination: `${base}/blackbox-exporter/`, status: 301 }, - [`${base}/sleep-peacefully.html`]: { destination: `${base}/sleep-peacefully/`, status: 301 }, -}; - export default defineConfig({ site: 'https://samber.github.io', base, - redirects: { ...buildRedirects(base), ...legacyHtmlRedirects }, + redirects: buildRedirects(base), output: 'static', integrations: [ sitemap({ diff --git a/site/public/robots.txt b/site/public/robots.txt index eff0940..411b4f3 100644 --- a/site/public/robots.txt +++ b/site/public/robots.txt @@ -1,5 +1,9 @@ User-agent: * Allow: / +Disallow: /awesome-prometheus-alerts/rules.html +Disallow: /awesome-prometheus-alerts/alertmanager.html +Disallow: /awesome-prometheus-alerts/blackbox-exporter.html +Disallow: /awesome-prometheus-alerts/sleep-peacefully.html # AI search bots — explicitly allowed for citation User-agent: GPTBot diff --git a/site/src/pages/alertmanager.html.astro b/site/src/pages/alertmanager.html.astro new file mode 100644 index 0000000..cdb2a86 --- /dev/null +++ b/site/src/pages/alertmanager.html.astro @@ -0,0 +1,16 @@ +--- +const base = import.meta.env.BASE_URL.replace(/\/$/, ''); +const destination = `${base}/alertmanager/`; +--- + + + + + Redirecting… + + + + +

Redirecting to {destination}

+ + diff --git a/site/src/pages/blackbox-exporter.html.astro b/site/src/pages/blackbox-exporter.html.astro new file mode 100644 index 0000000..502ead9 --- /dev/null +++ b/site/src/pages/blackbox-exporter.html.astro @@ -0,0 +1,16 @@ +--- +const base = import.meta.env.BASE_URL.replace(/\/$/, ''); +const destination = `${base}/blackbox-exporter/`; +--- + + + + + Redirecting… + + + + +

Redirecting to {destination}

+ + diff --git a/site/src/pages/rules.html.astro b/site/src/pages/rules.html.astro new file mode 100644 index 0000000..e447221 --- /dev/null +++ b/site/src/pages/rules.html.astro @@ -0,0 +1,16 @@ +--- +const base = import.meta.env.BASE_URL.replace(/\/$/, ''); +const destination = `${base}/rules/`; +--- + + + + + Redirecting… + + + + +

Redirecting to {destination}

+ + diff --git a/site/src/pages/sleep-peacefully.html.astro b/site/src/pages/sleep-peacefully.html.astro new file mode 100644 index 0000000..6a11ffe --- /dev/null +++ b/site/src/pages/sleep-peacefully.html.astro @@ -0,0 +1,16 @@ +--- +const base = import.meta.env.BASE_URL.replace(/\/$/, ''); +const destination = `${base}/sleep-peacefully/`; +--- + + + + + Redirecting… + + + + +

Redirecting to {destination}

+ +