Reputation: 1
I was wondering if anyone knows how to get the sitemap.xml
functionality working in Spartacus site like how it was working in yacceleratorstorefront/sitemap.xml
.
Looks like SAP Commerce Support team is still having this functionality in their roadmaps. But we need to implement sitemap.xml
for making the site live
We tried implementing the sitemap.xml
in same way like other pages in Spartacus site. But it is getting rendered as HTML if we view the source. But we need to load the sitemap.xml
file in XML format only when we view the source.
Any help would be much appreciated. Thank you :)
Upvotes: 0
Views: 497
Reputation: 413
If you don't want your sitemap.xml
to be rendered as HTML if you view the source, only the true xml asset, just place that in /assets/sitemap
and define it as an asset.
angular.json -> architect/projectname/build/options
"assets": [
//...
"src/assets",
{ "glob": "**/*sitemap.xml", "input": "src/assets/sitemap", "output": "/" }
],
Upvotes: 0
Reputation: 1243
Serving Spartacus-based site is a bit complicated. There are other workarounds.
First suggestion:
Use SAP Commerce capabilities to generate sitemap.xml
files. Save them to your web server and configure your web server (Nginx/Apache) to serve them at your backend.
Second suggestion
If your Spartacus storefront is running on an Express.js or Node.js server, modify it to serve your sitemap.xml file. Use a task scheduler to generate the sitemap.xml
file regularly and save it to your server.
Upvotes: 0