-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
add extra tags to <head> per page #894
Comments
currently, there is no easy way to do that. but if you willing to set it manually, you can read this https://vuepress.vuejs.org/guide/custom-themes.html#site-and-page-metadata update again: |
Thanks, i made some "dirty fix" as per page script
But I'll be appreciate for more "elegant" solution :) |
@pontius-g I'm using v0.14 where did you place that script? |
With a few correction, placed right to the bottom of .md file, where it’s needed
|
@pontius-g it's easier when the theme is ejected |
I didn’t eject the theme to stay covered with further updates implicitly |
it doesnt work for me ? |
pretty brief ))
Now u only need to define |
We're closing this issue as stale as it's more than 20 days without activity, and there are many workarounds as above. |
I made a plugin according previous discussions on this issue. Just try npm i vuepress-plugin-canonical -D then modify module.exports = {
plugins: [
[
'vuepress-plugin-canonical',
{
baseURL: 'https://mina.wiki', // base url for your canonical link, optional, default: ''
stripExtension: true // strip '.html' , optional, default: false
}
]
]
} |
@IOriens @ulivz What is shown here is not a valid solution. The canonical link gets added to the |
initialy, canonical meta-tag was needed for search-engine indexing purpose which is irrelevant for SPA behavior. |
@pontius-g No argument as to the purpose of the canonical tag - but link tags are used as a web standard not only for SEO, but for rendering other JavaScript content (e.g. AMP pages). Hoping a future VuePress update will allow for injecting these tags as needed. I posted a start to a possible change that could be implemented on another issue that would allow for setting |
I'm not an expert on Vuepress or Vue, but I stumbled upon this while trying to add default canonical tag. I ended up writing a small custom plugin that automatically adds the canonical tag if it's not defined in the frontmatter. It relies on the https://vuepress.vuejs.org/guide/frontmatter.html#canonicalurl config which is available from 1.7.1 module.exports = (options, context) => ({
name: 'vuepress-default-canonical',
extendPageData($page) {
const { frontmatter } = $page
// If no canonicalUrl is explictly defined in the Frontmatter, add it based on the permaLink
if (!frontmatter.canonicalUrl && frontmatter.permalink) {
frontmatter.canonicalUrl = `${$page?._context?.themeConfig?.domain}${frontmatter.permalink}`
return
}
if (!frontmatter.permalink && $page._permalink) {
// Set the canonical URL to theme pages (which don't have a frontmatter permalink)
frontmatter.canonicalUrl = `${$page?._context?.themeConfig?.domain}`
}
},
}) Note this relies on |
Hi
Help me please!
I there is a way to add custom tags into '<head>' section per page basis?
In example, adding <link rel='canonical' ...> ?
The text was updated successfully, but these errors were encountered: