harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
1.02k stars 63 forks source link

Automatic Image Discovery not working #301

Closed michael-picard closed 1 week ago

michael-picard commented 3 weeks ago

Describe the bug

My site is generated with Nuxt content. Despite the page content being inside a main tag the sitemap shows zero image when there is one.

Screenshot 2024-08-22 at 08 35 23 Screenshot 2024-08-22 at 08 35 40

Reproduction

https://stackblitz.com/~/github.com/michael-picard/cv-2024?file=README.md&initialPath=/blog/languages/php/php-weakmap

System / Nuxt Info

- Operating System: `Darwin`
- Node Version:     `v22.0.0`
- Nuxt Version:     `3.12.4`
- CLI Version:      `3.12.0`
- Nitro Version:    `2.9.7`
- Package Manager:  `npm@10.5.1`
- Builder:          `-`
- User Config:      `future`, `devtools`, `site`, `build`, `modules`, `content`, `vite`, `app`, `nitro`, `sitemap`, `compatibilityDate`
- Runtime Modules:  `()`, `nuxt-particles@0.3.0`, `@nuxt/image@1.7.0`, `@nuxt/content@2.13.2`, `@nuxtjs/sitemap@6.0.0-beta.4`
- Build Modules:    `-`
just-h commented 3 weeks ago

Same issue here, worth noting it only appears to happen with images generated by the nuxt/image module, at least for me.

Aravinda93 commented 2 weeks ago

@just-h @michael-picard I am also facing the same issue with Nuxt/Content. Have you guys found any workaround or alternative approach for this? I am also following up on this and posted here: https://github.com/harlan-zw/nuxt-seo/issues/298

Due to this issue, my production deployment has been blocked so wanted to see if I can figure out a work-around until we have a final fix.

Aravinda93 commented 2 weeks ago

Same issue here, worth noting it only appears to happen with images generated by the nuxt/image module, at least for me.

@just-h

I guess its works for both Nuxt images and normal images because in my case I tried with both and both seem to fail to generate for images: https://github.com/harlan-zw/nuxt-seo/issues/298

harlan-zw commented 1 week ago

I've tested with 6.0.0-rc.4 and it appears to be working correctly, please upgrade.

image

just-h commented 1 week ago

@michael-picard @Aravinda93 Manually adding 6.0.0-beta.5 of the sitemap module fixed it for me. As of right now the lastest nuxt-seo module itself still loads the beta.2 of the sitemap as a dependency, where the issue appears to be present for my stack, so adding the sitemap module separately seems to be a functioning workaround.

Aravinda93 commented 1 week ago

@michael-picard @Aravinda93 Manually adding 6.0.0-beta.5 of the sitemap module fixed it for me. As of right now the lastest nuxt-seo module itself still loads the beta.2 of the sitemap as a dependency, where the issue appears to be present for my stack, so adding the sitemap module separately seems to be a functioning workaround.

@just-h

Thanks a lot its working fine now with ssr:true and able to get the images in sitemap.xml file. But I am facing one small issue:

I have a few tags in my .md files; if the tags have spaces, then the spaces are retained in the generated URL within the sitemap.xml file. Can you please let me know how to fix this?

I have a Nuxt content website with some of the markdown files in /content/index.md with tags such as:

  navigation:
  linkTitle: "Introduction"
  tags : ["Testing tools", "performance tests", "process automation", "supply chain management", "load tests"]

I am generating the sitemap.xml using the nuxtjs/sitemap with ssr:true during the generation of the sitemap it generates the URL with spaces such as:

 <url>
    <loc>http://localhost:3000/tags/performance tests</loc>
    <xhtml:link rel="alternate" href="http://localhost:3000/tags/performance tests" hreflang="x-default" />
    <xhtml:link rel="alternate" href="http://localhost:3000/tags/performance tests" hreflang="en" />
</url>

Since it generates the URL with spaces they are invalid but URLs are valid when I navigate to them then they are present with spaces:

http://localhost:3000/tags/performance%20tests

How to ensure the sitemap adds appropriate spaces and checks for valid URLs before generating the sitemap.xml using Nuxt Sitemap and replacing the spaces with URL-safe characters.