API Calls
- Generate Sitemap:
GET /sitemap.xml - Retrieve Robots.txt:
GET /robots.txt
API Documentation
1. Generate Sitemap
Endpoint:/sitemap.xmlMethod:
GETDescription:
Dynamically generates a gzip-compressed sitemap.xml file by aggregating URLs from your site. This includes:
- Static pages: e.g.,
/,/contact,/about - Dynamic content: All published blogs (where
draft: false) and all active categories (whereisActive: true)
The response is a gzip-compressed XML document conforming to the sitemaps.org protocol. When decompressed, it resembles:
2. Retrieve Robots.txt
File:robots.txtMethod:
GETDescription:
The robots.txt file instructs search engine crawlers on which parts of your site to index or ignore, and specifies the URL of the sitemap. Response Example:
Setup & Deployment
1. Backend Setup
Dependencies:
Ensure the sitemap package is installed in your backend:Sitemap Route:
Create a file namedsitemap.routes.js in your backend’s routes folder with the following content:
Mount the Route:
In your main server file (e.g.,server.js), import and mount the sitemap router:
2. Environment Configuration
Ensure you have the correct environment variable in your.env file:
3. Robots.txt Configuration
Place or update therobots.txt file in the root of your public directory with:
4. Search Engine Submission
Once deployed, verify your sitemap is accessible athttps://yourdomain.com/sitemap.xml. Submit this URL to Google Search Console, Bing Webmaster Tools, and other search engines.
Conclusion
The Sitemap and SEO Management module ensures that all static and dynamic URLs on your site are automatically indexed. Configuring your environment variables and updating therobots.txt file guarantees proper SEO optimization without manual updates.
Sitemap Automation Tip: Yoursitemap.xmlis generated dynamically upon each request. Ensure yourrobots.txtreferences the correct sitemap URL and submit it to search engines.
Example Usage
1. Using SEO Component in a Category Page
If you want the title to display the category name and its description (e.g., “Programming · Learn coding”), compute the title and pass it to the SEO component:2. SEO Component Implementation (src/components/SEO.jsx)
Deployment & Usage
1. No Manual Updates Required
- The
sitemap.xmlis generated dynamically when accessed. - New blogs and categories are automatically added.
2. Robots.txt Update
Ensure yourrobots.txt file (placed in the public folder or served via a route) includes the correct sitemap URL:
3. Submitting to Search Engines
After deployment, submit your sitemap URL to Google Search Console and Bing Webmaster Tools to improve indexing.Final Notes
Dynamic and Flexible
- The sitemap is always up to date with no manual intervention.
- Meta tags are generated dynamically per page.
Comprehensive SEO
- The SEO component ensures structured meta tags.
- The automatically generated sitemap improves search engine indexing and ranking.

