We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
<link>
1 parent fcf828c commit 9510cd7Copy full SHA for 9510cd7
docs/reference/site-config.md
@@ -645,6 +645,23 @@ export default {
645
}
646
```
647
648
+#### Example: Adding a canonical URL `<link>`
649
+
650
+```ts
651
+export default {
652
+ transformHead({ page }) {
653
+ // Skip the 404 page
654
+ if (page !== '404.md') {
655
+ const canonicalUrl = `https://example.com/${page}`
656
+ .replace(/index\.md$/, '')
657
+ .replace(/\.md$/, '.html')
658
659
+ return [['link', { rel: 'canonical', href: canonicalUrl }]]
660
+ }
661
662
+}
663
+```
664
665
### transformHtml
666
667
- Type: `(code: string, id: string, context: TransformContext) => Awaitable<string | void>`
0 commit comments