diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index ae54951..fc1114e 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -24,6 +24,9 @@ interface Props { tags?: string[]; category?: string; }; + // Error pages: emit noindex and skip the canonical (a canonical pointing at a + // page that does not exist is worse than none). + noindex?: boolean; } const { @@ -35,6 +38,7 @@ const { switchHref, altLocaleUrl, article, + noindex = false, } = Astro.props; const canonical = new URL(Astro.url.pathname, SITE.url).href; @@ -71,7 +75,7 @@ const nav = isZh {title} - + {noindex ? : } {hreflang.map((alt) => ( diff --git a/src/pages/404.astro b/src/pages/404.astro index 1ae4074..63efbac 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -15,6 +15,7 @@ const fmt = (d: Date) =>

404 — container exited (code 1)