Better SEO
This commit is contained in:
@ -8,6 +8,7 @@
|
|||||||
"start": "astro dev",
|
"start": "astro dev",
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
|
"astro": "astro",
|
||||||
"format": "prettier -w .",
|
"format": "prettier -w .",
|
||||||
"lint:eslint": "eslint . --ext .js,.ts,.astro",
|
"lint:eslint": "eslint . --ext .js,.ts,.astro",
|
||||||
"subfont": "subfont -ir --no-fallbacks --silent --root dist"
|
"subfont": "subfont -ir --no-fallbacks --silent --root dist"
|
||||||
@ -18,6 +19,7 @@
|
|||||||
"@astrojs/rss": "^1.0.0",
|
"@astrojs/rss": "^1.0.0",
|
||||||
"@astrojs/sitemap": "^1.0.0",
|
"@astrojs/sitemap": "^1.0.0",
|
||||||
"@astrojs/tailwind": "^1.0.0",
|
"@astrojs/tailwind": "^1.0.0",
|
||||||
|
"@astrolib/seo": "^0.2.0",
|
||||||
"@fontsource/inter": "^4.5.12",
|
"@fontsource/inter": "^4.5.12",
|
||||||
"@tailwindcss/typography": "^0.5.4",
|
"@tailwindcss/typography": "^0.5.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
import { AstroSeo } from "@astrolib/seo"
|
||||||
import { getImage } from '@astrojs/image';
|
import { getImage } from '@astrojs/image';
|
||||||
import { getRelativeUrlByFilePath } from '~/utils/directories';
|
import { getRelativeUrlByFilePath } from '~/utils/directories';
|
||||||
|
|
||||||
@ -19,9 +20,13 @@ const {
|
|||||||
title = SITE.name,
|
title = SITE.name,
|
||||||
description = '',
|
description = '',
|
||||||
image: _image = defaultImage,
|
image: _image = defaultImage,
|
||||||
|
|
||||||
canonical,
|
canonical,
|
||||||
noindex = false,
|
noindex = false,
|
||||||
nofollow = false,
|
nofollow = false,
|
||||||
|
|
||||||
|
ogTitle = title,
|
||||||
|
ogType = 'website',
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
const image =
|
const image =
|
||||||
@ -35,30 +40,33 @@ const image =
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
<title>{title}</title>
|
<AstroSeo
|
||||||
<meta name="description" content={description} />
|
title={title}
|
||||||
{canonical && <link rel="canonical" href={canonical} />}
|
description={description}
|
||||||
|
|
||||||
<meta name="robots" content={`${noindex ? 'noindex' : 'index'}, ${nofollow ? 'nofollow' : 'follow'}`} />
|
canonical={canonical}
|
||||||
|
noindex={noindex}
|
||||||
|
nofollow={nofollow}
|
||||||
|
|
||||||
<!-- Google / Search Engine Tags -->
|
openGraph={{
|
||||||
<meta itemprop="name" content={title} />
|
url: canonical,
|
||||||
<meta itemprop="description" content={description} />
|
title: ogTitle,
|
||||||
{image && <meta itemprop="image" content={image} />}
|
description: description,
|
||||||
|
type: ogType,
|
||||||
<!-- Facebook Meta Tags -->
|
images: image ? [
|
||||||
{canonical && <meta property="og:url" content={canonical} />}
|
{
|
||||||
<meta property="og:type" content="website" />
|
url: image.toString(),
|
||||||
<meta property="og:title" content={title} />
|
alt: ogTitle,
|
||||||
<meta property="og:description" content={description} />
|
},
|
||||||
{image && <meta property="og:image" content={image} />}
|
] : undefined,
|
||||||
|
// site_name: 'SiteName',
|
||||||
<!-- Twitter Meta Tags -->
|
}}
|
||||||
{canonical && <meta name="twitter:url" content={canonical} />}
|
twitter={{
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
// handle: '@handle',
|
||||||
<meta name="twitter:title" content={title} />
|
// site: '@site',
|
||||||
<meta name="twitter:description" content={description} />
|
cardType: image ? 'summary_large_image' : undefined,
|
||||||
{image && <meta name="twitter:image" content={image} />}
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Fonts />
|
<Fonts />
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ const meta = {
|
|||||||
title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(page.url.current)),
|
canonical: getCanonical(getPermalink(page.url.current)),
|
||||||
|
ogType: "blog"
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ const meta = {
|
|||||||
description: post.description,
|
description: post.description,
|
||||||
canonical: post.canonical || getCanonical(getPermalink(post.slug, 'post')),
|
canonical: post.canonical || getCanonical(getPermalink(post.slug, 'post')),
|
||||||
image: await findImage(post.image),
|
image: await findImage(post.image),
|
||||||
|
ogTitle: post.title,
|
||||||
|
ogType: "article"
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -38,10 +38,11 @@ const meta = {
|
|||||||
title: `Category '${category}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
title: `Category '${category}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(page.url.current)),
|
canonical: getCanonical(getPermalink(page.url.current)),
|
||||||
|
noindex: true,
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout meta={{ ...meta, noindex: true }}>
|
<Layout meta={meta}>
|
||||||
<Fragment slot="title">
|
<Fragment slot="title">
|
||||||
Category: {category}
|
Category: {category}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
@ -38,10 +38,11 @@ const meta = {
|
|||||||
title: `Posts by tag '${tag}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
title: `Posts by tag '${tag}' ${currentPage > 1 ? `— Page ${currentPage} ` : ''}— ${SITE.name}`,
|
||||||
description: SITE.description,
|
description: SITE.description,
|
||||||
canonical: getCanonical(getPermalink(page.url.current)),
|
canonical: getCanonical(getPermalink(page.url.current)),
|
||||||
|
noindex: true
|
||||||
};
|
};
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout meta={{ ...meta, noindex: true }}>
|
<Layout meta={meta}>
|
||||||
<Fragment slot="title">
|
<Fragment slot="title">
|
||||||
Tag: {tag}
|
Tag: {tag}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
Reference in New Issue
Block a user