Generate dynamic sitemap with js?

白昼怎懂夜的黑 提交于 2020-01-24 20:16:24

问题


I have a small site, it has a bit of dynamic tabbed content which is loaded from a JSON file via an AJAX request and used to populate the DOM, the tabs themselves and content they contain are all generated on the fly from this JSON. This is all tied together with History.js so each tab is bookmarkable and indexable via a url: ?state=whatever.

I'm now looking to put together a sitemap.xml to submit to Google which contains all the URLs for the relevant tabs.

However, There is no server-side processing for the site, it is all static content served up in an S3 bucket.

I'm looking to see if there is a way, using purely font-end technologies to generate the sitemap from the same JSON file which is used to populate the various tabs.

Any ideas or suggestions?

Thanks,

Robert


回答1:


For a bot to use your sitemap.xml, it has to be an actual file living on your server.

To create the file, you will need a server-side language to create it dynamically. This could be PHP, ColdFusion, .NET or whatever you like.

Here's what I would do:

Post your JSON object (holding your links in the site) to an AJAX request, to a server-side script that will take this data and then generate a file called sitemap.xml.

Does that help? Sorry if I am mis-understanding your question.




回答2:


No, there isn't, the bot retrieving the sitemap will not run the javascript.



来源:https://stackoverflow.com/questions/11628588/generate-dynamic-sitemap-with-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!