Skip to content

Commit

Permalink
Add dynamic cononical url (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillHannon-MCB authored Sep 16, 2024
1 parent 8129b58 commit 5424d75
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@ export default defineConfig({
},
],
],
// Add canonical link to each page (https://vitepress.dev/reference/site-config#example-adding-a-canonical-url-link)
// It's necessary to do this because we need to tell google that we're hosting from jbloomlab.org and not from github.io
transformPageData(pageData) {
const canonicalUrl = `https://jbloomlab.org/${pageData.relativePath}`
.replace(/index\.md$/, "")
.replace(/\.md$/, ".html");

pageData.frontmatter.head ??= [];
pageData.frontmatter.head.push([
"link",
{ rel: "canonical", href: canonicalUrl },
]);
},
});

0 comments on commit 5424d75

Please sign in to comment.