diff --git a/src/components/common/MetaTags.astro b/src/components/common/MetaTags.astro index 3c3dd24..9252d98 100644 --- a/src/components/common/MetaTags.astro +++ b/src/components/common/MetaTags.astro @@ -2,9 +2,11 @@ import { AstroSeo } from '@astrolib/seo'; import { GoogleAnalytics } from '@astrolib/analytics'; import { getImage } from '@astrojs/image'; -import { getRelativeUrlByFilePath } from '~/utils/directories'; import { SITE } from '~/config.mjs'; +import { getCanonical } from '~/utils/permalinks'; +import { getRelativeUrlByFilePath } from '~/utils/directories'; + import Fonts from '~/components/common/Fonts.astro'; import ExtraMetaTags from '~/components/common/ExtraMetaTags.astro'; import SplitbeeAnalytics from './SplitbeeAnalytics.astro'; @@ -31,7 +33,7 @@ const { description = '', image: _image = defaultImage, - canonical, + canonical = getCanonical(String(Astro.url.pathname)), noindex = false, nofollow = false, diff --git a/src/pages/[...blog]/[...page].astro b/src/pages/[...blog]/[...page].astro index 27fbd4d..d8c7122 100644 --- a/src/pages/[...blog]/[...page].astro +++ b/src/pages/[...blog]/[...page].astro @@ -24,7 +24,6 @@ const currentPage = page.currentPage ?? 1; const meta = { title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, description: SITE.description, - canonical: getCanonical(getPermalink(BLOG?.blog?.pathname)), ogType: 'blog', noindex: currentPage > 1, }; diff --git a/src/pages/[...blog]/[category]/[...page].astro b/src/pages/[...blog]/[category]/[...page].astro index f2e3fdb..ae9b488 100644 --- a/src/pages/[...blog]/[category]/[...page].astro +++ b/src/pages/[...blog]/[category]/[...page].astro @@ -6,7 +6,7 @@ import BlogList from '~/components/blog/List.astro'; import Pagination from '~/components/common/Pagination.astro'; import { fetchPosts } from '~/utils/posts'; -import { getCanonical, getPermalink, cleanSlug, CATEGORY_BASE } from '~/utils/permalinks'; +import { cleanSlug, CATEGORY_BASE } from '~/utils/permalinks'; import Title from '~/components/blog/Title.astro'; export async function getStaticPaths({ paginate }) { @@ -36,7 +36,6 @@ const currentPage = page.currentPage ?? 1; const meta = { title: `Category'${category}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, description: SITE.description, - canonical: getCanonical(getPermalink(category, 'category')), noindex: true, }; --- diff --git a/src/pages/[...blog]/[slug].astro b/src/pages/[...blog]/[slug].astro index 85bbf9d..252073d 100644 --- a/src/pages/[...blog]/[slug].astro +++ b/src/pages/[...blog]/[slug].astro @@ -27,7 +27,7 @@ const url = getCanonical(getPermalink(post.slug, 'post')); const meta = { title: post.title, description: post.description, - canonical: post.canonical || url, + canonical: post.canonical || undefined, image: await findImage(post.image), ogTitle: post.title, ogType: 'article', diff --git a/src/pages/[...blog]/[tag]/[...page].astro b/src/pages/[...blog]/[tag]/[...page].astro index c7811e2..7019404 100644 --- a/src/pages/[...blog]/[tag]/[...page].astro +++ b/src/pages/[...blog]/[tag]/[...page].astro @@ -36,7 +36,6 @@ const currentPage = page.currentPage ?? 1; const meta = { title: `Posts by tag '${tag}'${currentPage > 1 ? ` — Page ${currentPage} ` : ''}`, description: SITE.description, - canonical: getCanonical(getPermalink(tag, 'tag')), noindex: true, }; --- diff --git a/src/pages/index.astro b/src/pages/index.astro index febe535..7894c06 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -17,7 +17,6 @@ import CallToAction from '~/components/widgets/CallToAction.astro'; const meta = { title: SITE.title, description: SITE.description, - canonical: getCanonical(getHomePermalink()), dontUseTitleTemplate: true, }; ---