How do i show image from public in header?
Currently i use this to get the image url:
But this doesnt work in
nuxt generate
it just returns the real path on the hard drive. (Example: ) Not the dynamic path from nuxt.
What is the default way to get the image urls for meta tags?3 Replies
Hey, import.meta.url is not the right variable to use here. Check out: https://unhead.harlanzw.com/guide/guides/useseometa for a general docs on this.
Since your nuxt generate doesn’t know on which domain it lives, if you want to make that part dynamic, you have to set a runtimeConfig.public variable in your nuxt.config.ts.
So in your case (notice we don't need
/public
) since your /image/test.png
will be served from the domain root.
-- or --
using
Is a good solution for dev and prod env thanks!