Nextjs Sitemap Generator

Generate sitemap.xml from nextjs pages

Digital Marketing & SEOTypeScriptMIT

Abstract

Nextjs Sitemap Generator is an open-source Digital Marketing & SEO project. Generate sitemap.xml from nextjs pages. See this to understand how to do it (https://nextjs.org/docs/api-reference/next.config.js/exportPathMap) (OPTIONAL). It is built using TypeScript, Next.js. The complete source code is publicly available on GitHub under the MIT License, making it a useful reference for students building a Digital Marketing & SEO mini project or final-year project.

1. Introduction

See this to understand how to do it (https://nextjs.org/docs/api-reference/next.config.js/exportPathMap) (OPTIONAL)

We are looking for maintainers because I don't have enough time to maintain the package.

2. Objective

Generate sitemap.xml from nextjs pages

This project demonstrates how TypeScript, Next.js can be applied to a real-world Digital Marketing & SEO problem.

4. Technology Stack

TypeScriptNext.js

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Node.js (LTS) and npm / yarn / pnpm
  • VS Code or any code editor
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/IlusionDev/nextjs-sitemap-generator.git
cd nextjs-sitemap-generator
yarn add nextjs-sitemap-generator
npm i --save-dev nextjs-sitemap-generator
const sitemap =  require("nextjs-sitemap-generator");

const fs =  require("fs");



const BUILD_ID = fs.readFileSync(".next/BUILD_ID").toString();



sitemap({
  baseUrl: "https://example.com",
  // If you are using Vercel platform to deploy change the route to /.next/serverless/pages
  pagesDirectory: __dirname + "/.next/server/static/" + BUILD_ID + "/pages",
  targetDirectory: "public/",
  ignoredExtensions: ["js", "map"],
  ignoredPaths: ["assets"], // Exclude everything that isn't static page
});

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Export reports to Google Sheets or PDF
  • Schedule weekly automated reports
  • Add competitor comparison

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. Which marketing or SEO problem does this tool solve?
  2. Which data sources or APIs does it use (Search Console, Analytics, social platforms)?
  3. Which metrics or KPIs does it report and how are they calculated?
  4. How could the output help a business make decisions?
  5. How would you schedule it to run automatically?

9. Source Code & License

This project is developed by IlusionDev and published on GitHub under the MIT License. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on a Digital Marketing & SEO project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for Digital Marketing & SEO Internship