schema-org
schema-org copied to clipboard
dynamic canonicalHost
I have multi site with different host running the same app. How can I make it dynamically setting in the app, since the config is built time setting.?
Can we set the host in runtime? as all my site info is stored in database.
ok, I found it. I can change the canonicalhost in runtime now.
injectSchemaOrg().options.canonicalHost = 'https://google.com/'
Hey @shtse8
Glad you could resolve this one by yourself! I think this may be the best option for the time being, if you think a better implementation is required feel free to open another issue :)
@harlan-zw I hate setting hostname in config as it may be changed in runtime. For example, different hostname for dev env and prod env. Moving site from one domain to another. Changing subdomain or multiple tld .cn
, .com
for serving to China and international correspondingly.
If hostname is set in config, build is needed for change. And we can't store it as info data in database.
So I would suggest that providing a setter method for setting it in runtime and don't warn user if there is no hostname provided in config. 🙏
setCanonicalHost(host: MayBeRef<string>)
Hey @shtse8
Just wanted to update you on the new v1 behaviour.
Not sure which integration you're using, but if you're using Nuxt then you can make use of the NuxtApp hooks to override any meta.
You can see an example here: https://vue-schema-org.netlify.app/guide/getting-started/nuxt#nuxtapp-hooks
WIll close this off, but feel free to re-open if there's any issues with it