Steps to Generate Static Sitemap in MERN Application

If the website you are working on has a fixed number of URLs, for example, your portfolio. You can generate a sitemap.xml file with the help of any online tool and place the folder in the src folder.

Step 1: Visit https://www.xml-sitemaps.com/ and generate the sitemap.xml file.

Step 2: Move the file into the public folder of your react app.

Project Structure:

Step 3: Verify the changes by visiting https://ahampriyanshu.com/sitemap.xml.

Step 4: Finally, Add the Sitemap to your robots.txt file

User-agent: *
Allow: /
Sitemap: https://baseurl/sitemap.xml

How to Generate Sitemap in a MERN Application ?

Generate Sitemap in a MERN Application refers to creating a file that lists the pages, videos, and other files on your website, as well as their relationships. Search engines (such as Google, Duckduckgo, Bing, and others) use this file to help them crawl your site more efficiently.

Similar Reads

Prerequisites:

MERN Stack NPM & Node.js Sitemap...

Steps to Generate Static Sitemap in MERN Application :

If the website you are working on has a fixed number of URLs, for example, your portfolio. You can generate a sitemap.xml file with the help of any online tool and place the folder in the src folder....

Steps to Generate Dynamic Sitemap :

So far we have discussed creating a sitemap with static URLs. But what if the number of URLs and the content of existing URLs change from time to time. Suppose we are creating a GFG clone. So, our sitemap should contain URLs of all the articles and the important pages. For this, we will send a sitemap file from our backend by first looping through all the required records from our database. After this, we will manually add the URLs of other important pages like about, contact, etc....

Contact Us