feat: add meta tags, and links, and other SEO optimization to the head

This commit is contained in:
Stefan Imhoff
2023-06-12 17:41:22 +02:00
parent 15daaa39e1
commit a823e2ff9b
14 changed files with 179 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
---
title: Shokunin The Spirit of an Artisan
slug: shokunin
date: 2023-03-08
author: Stefan Imhoff
description: The Japanese word “shokunin” describes an artisan or craftsman. In this essay, I investigate the meaning and history of the word and show a variety of examples.

View File

@@ -1,6 +1,8 @@
---
import '../styles/global.css';
import { Sprite } from 'astro-icon';
import { SEO } from 'astro-seo';
import { site } from '../data/site';
import ThemeProvider from '../components/ThemeProvider.astro';
import PageHeader from '../components/PageHeader.astro';
@@ -9,52 +11,142 @@ import Sal from '../components/Sal.astro';
export interface Props {
backLink?: string;
cover?: string;
description?: string;
footer?: boolean;
header?: boolean;
nofollow?: boolean;
noindex?: boolean;
title: string;
}
const { backLink, footer = true, header = true, title, description } = Astro.props;
const {
backLink,
description,
footer = true,
header = true,
nofollow,
noindex,
title,
cover = '/assets/images/branding/og/bonsai.jpg',
} = Astro.props;
const currentPath = new URL(Astro.request.url).pathname;
const fullTitle = `${title} · ${site.description}`;
const fullDescription = description || site.description;
const fullUrl = site.url + currentPath;
const fullImage = site.url + cover;
---
<!DOCTYPE html>
<html lang="en" class="no-js box-border scroll-smooth text-[125%]">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<meta name="description" content={description} />
<SEO
charset="UTF-8"
title={fullTitle}
description={fullDescription}
canonical={fullUrl}
nofollow={nofollow}
noindex={noindex}
openGraph={{
basic: {
image: fullImage,
title: fullTitle,
type: 'article',
url: fullUrl,
},
image: {
height: 675,
width: 1200,
},
optional: {
description: fullDescription,
},
}}
twitter={{
card: 'summary_large_image',
creator: site.twitter,
description: fullDescription,
image: fullImage,
site: site.twitter,
title: fullTitle,
}}
extend={{
link: [
{ rel: 'icon', href: '/favicon.ico' },
{
rel: 'icon',
href: '/assets/images/branding/favicons/favicon.svg',
type: 'image/svg+xml',
},
{
rel: 'apple-touch-icon',
href: '/assets/images/branding/favicons/apple-touch-icon.png',
},
{
rel: 'manifest',
href: '/manifest.webmanifest',
},
{
as: 'font',
crossorigin: '',
href: '/assets/fonts/secuela-regular-vf.woff2',
rel: 'preload',
type: 'font/woff2',
},
{
as: 'font',
crossorigin: '',
href: '/assets/fonts/secuela-italic-vf.woff2',
rel: 'preload',
type: 'font/woff2',
},
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Stefan Imhoff',
href: site.url + '/rss.xml',
},
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Stefan Imhoff (Haiku)',
href: site.url + '/rss-haiku.xml',
},
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Stefan Imhoff (Sketchnotes)',
href: site.url + '/rss-sketchnotes.xml',
},
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Stefan Imhoff (AI Art)',
href: site.url + '/rss-ai-art.xml',
},
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Stefan Imhoff (Projects)',
href: site.url + '/rss-projects.xml',
},
],
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'author', content: site.author },
{ name: 'generator', content: Astro.generator },
{ name: 'theme-color', content: '#e7e6e4' },
],
}}
/>
<script type="module">
document.documentElement.classList.remove('no-js');
document.documentElement.classList.add('js');
</script>
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" href="/assets/images/branding/favicons/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/assets/images/branding/favicons/apple-touch-icon.png" />
<!-- <link rel="manifest" href="/manifest.webmanifest" /> -->
<link
as="font"
crossorigin
href="/assets/fonts/secuela-regular-vf.woff2"
rel="preload"
type="font/woff2"
/>
<link
as="font"
crossorigin
href="/assets/fonts/secuela-italic-vf.woff2"
rel="preload"
type="font/woff2"
/>
<Sal />
<ThemeProvider />
</head>
<body

View File

@@ -6,24 +6,30 @@ import BaseLayout from './BaseLayout.astro';
export interface Props {
backLink?: string;
class?: string;
cover?: string;
description?: string;
footer?: boolean;
gap?: boolean;
grid?: 'fullsize' | 'wide' | 'narrow';
header?: boolean;
innerGrid?: boolean;
nofollow?: boolean;
noindex?: boolean;
title: string;
}
const {
backLink,
class: className,
cover,
description,
footer = true,
gap = true,
grid = 'narrow',
header,
innerGrid,
nofollow,
noindex,
title,
} = Astro.props;
@@ -48,10 +54,13 @@ const wrapperClasses = cx(
<BaseLayout
backLink={backLink}
cover={cover}
description={description}
footer={footer}
header={header}
nofollow={nofollow}
noindex={noindex}
title={title}
description={description}
>
<div class={gridClasses}>
<slot name="title" />

View File

@@ -13,7 +13,15 @@ const title = 'Error 404';
const description = 'Page not found.';
---
<GridLayout title={title} description={description} grid="wide" class="grid" innerGrid>
<GridLayout
class="grid"
description={description}
grid="wide"
innerGrid
nofollow={true}
noindex={true}
title={title}
>
<PageTitle grid="wide" innerGrid>Not Found.</PageTitle>
<Verse
class="z-10 col-start-1 col-end-17 row-start-2 text-3 italic mbe-10 mbs-10 md:col-start-3 md:col-end-9"

View File

@@ -48,7 +48,16 @@ const title = entry.data.title;
const description = entry.data.description;
---
<GridLayout title={title} description={description} grid="fullsize" innerGrid backLink="/journal/">
<GridLayout
backLink="/journal/"
cover={entry.data.cover}
description={description}
grid="fullsize"
innerGrid
nofollow={entry.data.nofollow}
noindex={entry.data.noindex}
title={title}
>
<PageTitle slot="title" class="!text-6">
{entry.data.title}
</PageTitle>

View File

@@ -27,7 +27,15 @@ const description =
'The curriculum vitae of Stefan Imhoff, Senior Software Engineer from Hamburg, Germany.';
---
<GridLayout title={title} description={description} grid="wide" class="grid" innerGrid>
<GridLayout
class="grid"
description={description}
grid="wide"
innerGrid
nofollow={true}
noindex={true}
title={title}
>
<PageTitle grid="wide" innerGrid>Curriculum Vitae</PageTitle>
<article class="col-span-full md:col-start-1 md:col-end-9" {...animation}>

View File

@@ -2,6 +2,8 @@
layout: ../layouts/PageLayout.astro
title: Imprint
description: The imprint of this website.
noindex: true
nofollow: true
---
import { mapping } from "../mdx-components.ts";

View File

@@ -11,5 +11,7 @@ export const aiArt = defineCollection({
aspectRatio: z.number(),
})
),
noindex: z.boolean().optional(),
nofollow: z.boolean().optional(),
}),
});

View File

@@ -5,5 +5,7 @@ export const haiku = defineCollection({
date: z.date(),
de: z.string(),
en: z.string(),
noindex: z.boolean().optional(),
nofollow: z.boolean().optional(),
}),
});

View File

@@ -29,5 +29,7 @@ export const journal = defineCollection({
])
),
series: z.string().optional(),
noindex: z.boolean().optional(),
nofollow: z.boolean().optional(),
}),
});

View File

@@ -38,5 +38,7 @@ export const projects = defineCollection({
})
.optional(),
class: z.string().optional(),
noindex: z.boolean().optional(),
nofollow: z.boolean().optional(),
}),
});

View File

@@ -11,5 +11,7 @@ export const sketchnotes = defineCollection({
aspectRatio: z.number(),
})
),
noindex: z.boolean().optional(),
nofollow: z.boolean().optional(),
}),
});