New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add canonical tag in Gridsome blog? #1665
Comments
You can return an array of 'link' as well as 'meta'. An example below. I might have added siteUrl to the config to access it via a static query like is shown here. <script>
export default {
metaInfo() {
const pathUrl = `${this.$static.metadata.siteUrl}${this.$route.path}`
return {
link: [{ rel: 'canonical', href: pathUrl }],
meta: [{ property: 'og:url', content: pathUrl }],
}
},
}
</script> |
can you please implement this in above code and give full ? Thanks |
can I insert multiple <script> tag..? |
From your code, script will be like: <script>
export default {
metaInfo() {
return {
title: this.$page.documentation.title,
// just include a link property in this returned object here
link: [{ rel: 'canonical', href: `${this.getBaseUrl}${this.$page.documentation.path}/` }],
meta: [
{
key: 'description',
name: 'description',
content: this.$page.documentation.excerpt,
},
{ name: 'description', content: this.$page.documentation.excerpt },
{ name: 'twitter:card', content: 'summary_large_image' },
{
name: 'twitter:description',
content: this.$page.documentation.excerpt,
},
{ name: 'twitter:title', content: this.$page.documentation.title },
{
name: 'twitter:site',
content: `@${this.$static.metadata.siteAuthor}`,
},
{
name: 'twitter:image',
content: `${this.getBaseUrl}/default-thumb.png`,
},
{
name: 'twitter:creator',
content: `@${this.$static.metadata.siteAuthor}`,
},
{ property: 'og:type', content: 'document' },
{ property: 'og:title', content: this.$page.documentation.title },
{
property: 'og:description',
content: this.$page.documentation.excerpt,
},
{
property: 'og:url',
content: `${this.getBaseUrl}${this.$page.documentation.path}/`,
},
{
property: 'og:image',
content: `${this.getBaseUrl}/default-thumb.png`,
},
{
property: 'og:image:secure_url',
content: `${this.getBaseUrl}/default-thumb.png`,
},
],
}
},
components: {
AppSidebar: () => import('~/components/parts/AppSidebar'),
},
}
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: