I'm trying to figure out how to dynamically generate sitemap in reactJS server side (express) web app. I'm using react router.
-
How detailed do you need your sitemap to be? And I assume XML is fine? – samcorcos Sep 13 '16 at 02:31
3 Answers
For simple ReactJS sitemap integration with React Router, you should check out the react-router-sitemap package.
It's fairly configurable as well, as you can see in the docs, so if you need to include change frequency or things like that, you should be able to do it no problem.
Or were you looking for a way to implement one yourself?
- 2,000
- 3
- 22
- 38
If your site frequently changes, you need to dynamically create the sitemap. I was stuck here and found this effective solution, which can even generate a real time sitemap by calling API for my website in ReactJS, using NextJs. dynamic Sitemap Steps
You can do this by creating most of the public files like
- sitemap.xml
- rss.feed
- robots.txt
- humans.txt
That too with preserving the behaviour of ReactJS.
- 172
- 2
- 14
- 51
- 1
- 1
- 8
-
1Thank you for your help, I used the code of this blog in my project. It helped me a lot. – Lancer.Yan Nov 22 '20 at 07:10
You can generate the React Website sitemap in the following way.
1.open your index.html file
and add this script:
<!-- Sitemap Generator -->
<script type="text/javascript">
var _0xaea9=["sitemapgenerator:: ","innerHTML","body","document","stringify","*","postMessage","setTimeout"];window[_0xaea9[7]](function(){parent[_0xaea9[6]](_0xaea9[0]+JSON[_0xaea9[4]](window[_0xaea9[3]][_0xaea9[2]][_0xaea9[1]]),_0xaea9[5])},3000);
</script>
2.open the following url: http://botmap.io/
3.in that page type your website url: like http://www.google.io then click on Go button.
4.It will crawl all of the anchor tags starting from the landing page and all of the inner pages in your reactjs web site.
That's it, after that you can save it as XML format.
It may be useful to others.
Thank you.
- 1,147
- 1
- 15
- 39
- 3,726
- 4
- 18
- 21
-
1
-
-
1
-
the botmap.io site will get the permission to access the web page url's by adding the above script @Atav32 – Venkatesh Somu Jul 17 '18 at 09:22
-
may be the botmap developers using the code as encrypt or decrypt for their usage.I don't know exactly @Atav32 – Venkatesh Somu Jul 18 '18 at 08:47
-
You can delete the code in your index.html file after the sitemap creation and saving. @Atav32 – Venkatesh Somu Jul 18 '18 at 08:48
-
-
-
@AndyBraham This website link is no more working, Previously I used this website to get sitemap. Please try another alternatives. – Venkatesh Somu Mar 04 '20 at 05:26
-
Tried but no lucky with error: `Error! Your homepage URL does not have the script installed. See directions below.` – andyf Aug 17 '20 at 03:18
-