Skip to content

Commit c470154

Browse files
committed
Add Astro SEO package
1 parent 490373e commit c470154

File tree

3 files changed

+114
-3
lines changed

3 files changed

+114
-3
lines changed

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@astrojs/sitemap": "^3.1.4",
1717
"astro": "^4.8.6",
1818
"astro-icon": "^1.1.0",
19+
"astro-seo": "^0.8.4",
1920
"basiclightbox": "5.0.3",
2021
"rehype-figure": "^1.0.1",
2122
"remark-toc": "^9.0.0",

src/layouts/BaseLayout.astro

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,109 @@
11
---
2-
import BaseHead from "../components/BaseHead.astro";
2+
/* import BaseHead from "../components/BaseHead.astro"; */
33
import Header from "../components/Header.astro";
44
import Footer from "../components/Footer.astro";
55
import { SITE_TITLE, SITE_DESCRIPTION } from "../consts";
66
import Tawk from "../components/Tawk.astro";
77
import Analytics from "../components/Analytics.astro";
8+
import { SEO } from "astro-seo";
9+
import "../styles/styles.css";
10+
import heroImage from "../images/hero2.png";
11+
import { getImage } from "astro:assets";
12+
13+
const fallbackOgImage = await getImage({
14+
src: heroImage,
15+
format: "jpg",
16+
height: 200,
17+
});
18+
819
const {
920
current,
1021
animateHeader,
1122
withBorder,
1223
withIntercom,
1324
title = SITE_TITLE,
1425
description = SITE_DESCRIPTION,
15-
ogImage,
26+
ogImage = fallbackOgImage,
1627
} = Astro.props;
1728
---
1829

1930
<!doctype html>
2031
<html lang="en">
2132
<head>
2233
{import.meta.env.PROD && <Analytics />}
23-
<BaseHead title={title} description={description} ogImage={ogImage} />
34+
<!-- <BaseHead title={title} description={description} ogImage={ogImage} /> -->
35+
36+
<!-- Global Metadata -->
37+
<meta charset="utf-8" />
38+
<meta name="viewport" content="width=device-width,initial-scale=1" />
39+
40+
<link
41+
rel="apple-touch-icon"
42+
sizes="180x180"
43+
href="/apple-touch-icon.png?"
44+
/>
45+
<link
46+
rel="icon"
47+
type="image/png"
48+
sizes="32x32"
49+
href="/favicon-32x32.png?"
50+
/>
51+
<link
52+
rel="icon"
53+
type="image/png"
54+
sizes="16x16"
55+
href="/favicon-16x16.png?"
56+
/>
57+
<link rel="manifest" href="/site.webmanifest" />
58+
59+
<meta name="generator" content={Astro.generator} />
60+
61+
<!-- Sitemap -->
62+
<link rel="sitemap" href="/sitemap-index.xml" />
63+
64+
<!-- RSS -->
65+
<link
66+
rel="alternate"
67+
type="application/rss+xml"
68+
title={title}
69+
href={`${Astro.site}rss.xml`}
70+
/>
71+
72+
<!-- Font preloads -->
73+
<link
74+
rel="preload"
75+
href="/fonts/atkinson-regular.woff"
76+
as="font"
77+
type="font/woff"
78+
crossorigin
79+
/>
80+
<link
81+
rel="preload"
82+
href="/fonts/atkinson-bold.woff"
83+
as="font"
84+
type="font/woff"
85+
crossorigin
86+
/>
87+
88+
<SEO
89+
title={title}
90+
description={description}
91+
openGraph={{
92+
basic: {
93+
title: title,
94+
type: "website",
95+
image: new URL(ogImage.src, Astro.url).href,
96+
url: Astro.url,
97+
},
98+
}}
99+
twitter={{
100+
card: "summary_large_image",
101+
title: title,
102+
description: description,
103+
image: new URL(ogImage.src, Astro.url).href,
104+
creator: "@RockingML",
105+
}}
106+
/>
24107
</head>
25108

26109
<body id="top" class="ss-preload">

0 commit comments

Comments
 (0)