How do I create a sitemap for my Wasp website?
Apologies if this is a basic question and not strictly Wasp-specific.
I just want to make sure I'm following the right approach.
I'm looking to generate a sitemap for my website. Ideally, I want a new page to be added to a sitemap as soon as I add a new route to main.wasp file.
Could you please suggest the best way to create a sitemap that includes all pages automatically?
6 Replies
Hi @lucky72o. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Currently, Wasp doesn't have built-in functionality for automatically generating sitemaps based on your routes defined in
main.wasp
. This is a valid question about Wasp, but the knowledge sources don't contain specific information about sitemap generation.
Since Wasp uses React Router under the hood for routing, you would need to implement a manual solution. You could:
1. Create a sitemap.xml file manually based on your routes
2. Write a script that parses your main.wasp
file to extract routes and generate a sitemap
3. Use a third-party library compatible with React applications
For type-safe route handling, Wasp does provide a routes
object that you can use in your application:
This feature, described in Type-Safe Links, could potentially be used as part of a custom sitemap generation solution.
If you need more specific guidance on implementing sitemaps with Wasp, you might want to reach out to the Wasp team directly through Discord as mentioned in their contact page.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @lucky72o, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@lucky72o Seemed like an interesting problem, so I created a script to do this, using the sitemap package. The example package.json shows how you could use it to ensure the sitemap gets regenerated every time you start the app, but you could also incorporate it into your build/deploy process
Gist
Sitemap generator for Wasp apps
Sitemap generator for Wasp apps. GitHub Gist: instantly share code, notes, and snippets.
npm
sitemap
Sitemap-generating lib/cli. Latest version: 8.0.0, last published: a year ago. Start using sitemap in your project by running
npm i sitemap
. There are 404 other projects in the npm registry using sitemap.Wohooo @genyus, you just became a Waspeteer level 9!
Thanks @genyus , I will give it a go 👍
Thanks for jumping in @genyus.
@lucky72o I've added your message to the relevant issue to help prioritize it. Thanks for asking!
GitHub
Provide better direct support for static content in Wasp · Issue #...
We have some users that have content heavy apps: often it is a combo of an app and a blog of some kind (e.g. educational content). While we currently advise to use Wasp + something like Astro, this...
thanks!