-
-
Notifications
You must be signed in to change notification settings - Fork 67
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 set dynamic site name with Nuxt Seo version 2.x? #121
Comments
I tried to read the documentation more thoroughly, and according to this paragraph https://nuxtseo.com/site-config/guides/setting-site-config#programmatic-site-config-runtime it seems that what I'm trying to achieve could be done by the This is not extremely urgent, but can you please confirm that doing this is indeed possible by using that composable? |
Hi @stefanobartoletti, sorry for the delay. You have quite a number of options in updating the site config, all of them start from using Here's an example using a Nuxt server plugin. // plugins/site-config.server.ts
import { defineNuxtPlugin, updateSiteConfig, useRequestURL } from '#imports'
export default defineNuxtPlugin({
name: 'nuxt-site-config:overrides',
enforce: 1, // makes sure it's ran before nuxt-seo plugin
setup() {
const url = useRequestURL()
if (url.origin.includes('subdomain.host.com')) {
updateSiteConfig({
url: url.origin,
name: 'Subdomain',
description: 'Subdomain description',
})
}
},
}) Let me know if you have any questions on usage, will keep this open either way until it's properly documented. |
Thanks for your reply, I'll try this and let you know if it works in my current setup. |
Hi @harlan-zw, I'm writing again since I was not able to properly solve this via a plugin. Apparently, my particular setup based on data coming from Storyblok does not really support getting dynamic data out of the box, and would require me to create some complex custom functions (overriding their module) just to retrieve what is only a single string (for reference: storyblok/storyblok-nuxt#623) I tried to use Do you have more suggestions about how to use Thank you again for your support! |
Please see https://nuxtseo.com/site-config/guides/runtime-site-config, if you still have issues let me know! |
Details
This is probably related to #34 but specific to version 2.x of the module.
I currently have this configuration in my
layouts/default.vue
to dynamically set the site name, fetched from a CMSI also need to set the site title dynamically when using version 2, but the
SeoKit
component and composable are deprecated. I cannot find how to do this in the documentation (maybe it is there and it's only my bad :D ).How can I do this?
The text was updated successfully, but these errors were encountered: