Skip to content

Commit d6aaa22

Browse files
committed
[FIX] Canonical URL
1 parent 9a906b3 commit d6aaa22

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

app.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@
88
</template>
99
<script setup lang="ts">
1010
defineRobotMeta()
11+
const { origin } = useRequestURL()
12+
const route = useRoute()
13+
useHead({
14+
link: [
15+
{
16+
rel: 'canonical',
17+
href: `${origin}${route.path}`
18+
},
19+
],
20+
})
1121
</script>

components/template/CategoryPage.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ useHead({
3030
name: 'keywords',
3131
content: category.metaKeywords || ''
3232
}
33-
],
34-
link: [
35-
{
36-
hid: 'canonical',
37-
rel: 'canonical',
38-
href: `${protocol}//${host}/${category.urlKey}` || ''
39-
},
40-
],
33+
]
4134
})
4235
</script>

components/template/ProductPage.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ useHead(() => ({
3030
name: 'keywords',
3131
content: product.metaKeywords || ''
3232
},
33-
],
34-
link: [
35-
{
36-
hid: 'canonical',
37-
rel: 'canonical',
38-
href: `${protocol}//${host}/${product.urlKey}` || ''
39-
},
40-
],
33+
]
4134
}))
4235
</script>

0 commit comments

Comments
 (0)