Skip to content
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

Sitemap Plugin #1451

Open
mikhin opened this issue Jan 21, 2024 · 10 comments
Open

Sitemap Plugin #1451

mikhin opened this issue Jan 21, 2024 · 10 comments

Comments

@mikhin
Copy link

mikhin commented Jan 21, 2024

Description

Hello, Vike Community! I'm in search of a sitemap plugin to enhance our project and was wondering if such a feature already exists.

If not, I'd be grateful for any guidance or suggestions on how to elegantly implement this.

Thank you in advance for your time and assistance!

@mikhin mikhin added the enhancement 🚀 New feature or request label Jan 21, 2024
@brillout
Copy link
Member

What exactly do you mean with sitemap? Do you mean example.org/sitemap.xml? What's your motivation?

@mikhin
Copy link
Author

mikhin commented Jan 21, 2024

Yeah, sitemap.xml. I have ssr({prerender: true}) and a lot of html files after build phase, so I want to get somehow sitemap.xml after build step too.

@brillout
Copy link
Member

How about a prerender: { sitemap: true } option? Would you be up for a PR?

What's your motivation?

For SEO or other purposes as well? Is it still relevant to have a sitemap.xml for SEO?

@mikhin
Copy link
Author

mikhin commented Jan 21, 2024

Would you be up for a PR?

Yeah, I'm ready to get involved

What's your motivation?

In my particular case, I need it for SEO, yes. I want to feed the file into Google Search Console:

Screenshot 2024-01-21 at 21 11 33

@brillout
Copy link
Member

👍 Looking forward to it.

@mikhin
Copy link
Author

mikhin commented Jan 21, 2024

Could you suggest suitable internal APIs from Vike? What would it look like in theory?

I'm asking because I'm not familiar with the Vike structure.

@brillout
Copy link
Member

See runPrerender.ts. If you prefer you can write a script you run after an one of the example's $ vite build (e.g. /examples/{react,vue}-full and I'll do the integration of your script into Vike. Whichever you prefer.

@Idrinth
Copy link

Idrinth commented Jan 24, 2024

@mikhin if you want some code for a script that should work with minor adjustments feel free to take from https://github.com/Idrinth/react-file-based-routes/blob/master/src/generate-routes.ts - would be happy if vike would support sitemaps out of the box.

Required adjustments:

  • point to dist instead of src
  • look for .html files instead of .tsx
  • possibly adjust the mapping object

@mikhin
Copy link
Author

mikhin commented Jan 24, 2024

Sounds great, thanks for the tip!

@brillout
Copy link
Member

Quoting @br0wsa #2234.

I would be happy to [...] contribute to its development.

Yes, contribution welcome!

At least some rudimentary support for SEO purposes would be nice indeed. I guess simply generating dist/client/sitemap.xml with the list of URLs would be good enough for SEO purposes? IIRC / I guess search bots automatically try to fetch /sitemap.xml (no need to have a link to it).

Allows configuration options for generation, such as update frequency and page priority.

Not sure I follow this one: aren't sitemaps always static? Not sure what you mean with page priority.

Provides a simple user interface for downloading the XML sitemap file.

Interesting. What's the use case? 👀

We can add built-in support for sitemap.xml into Vike core, or create a Vike extension, or both. If all features make sense for most users we can make it all built-in, but we can (also) create Vike extensions for tailored use cases.

@brillout brillout marked this as a duplicate of #2234 Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants