Commit b4ba24b

HPCesia <me@hpcesia.com>
2026-09-18 09:42:57
layout: add more meta head tags
1 parent aaf87e6
Changed files (3)
src/layouts/BaseLayout.astro
@@ -13,16 +13,20 @@ interface Props {
   title?: string;
   author?: string;
   description?: string;
+  ogType?: "website" | "article";
 }
 
 const {
   title = SITE_CONFIG.title,
   author = SITE_CONFIG.author,
   description = SITE_CONFIG.description,
+  ogType = "website",
 } = Astro.props;
+
+const locale = SITE_CONFIG.locale;
 ---
 <!doctype html>
-<html lang={SITE_CONFIG.locale}>
+<html lang={locale}>
   <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width" />
@@ -37,6 +41,18 @@ const {
     <meta name="description" content={description} />
     <meta name="author" content={author} />
 
+    <link rel="alternate" hreflang={locale} href={Astro.url}>
+    <link rel="alternate" hreflang="x-default" href={Astro.url}>
+
+    <meta property="og:url" content={Astro.url} />
+    <meta property="og:site_name" content={SITE_CONFIG.title} />
+    <meta property="og:title" content={title} />
+    <meta property="og:description" content={description} />
+    <meta property="og:locale" content={locale} />
+    <meta property="og:type" content={ogType} />
+
+    <meta name="robots" content="noindex, nofollow">
+
     <Font cssVariable="--font-stix-two-math" />
   </head>
   <body>
src/pages/posts/[slug].astro
@@ -25,6 +25,7 @@ const { Content } = await render(entry);
   title={data.title}
   author={data.author}
   description={data.desc}
+  ogType="article"
 >
   <article>
     <Content />
src/pages/about.astro
@@ -10,7 +10,7 @@ import Article from "@/contents/about.typ";
 
 const globalI18n = getIntlayer("global", SITE_CONFIG.locale);
 ---
-<BaseLayout title={globalI18n.about}>
+<BaseLayout title={globalI18n.about} ogType="article">
   <article>
     <h1>{globalI18n.about}</h1>
     <Article />