Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

🗺️ The simplest way to add a sitemap to an express application

Notifications You must be signed in to change notification settings

jenbuzz/express-simple-sitemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

express-simple-sitemap

The simplest way to add a sitemap to an express application.

Installation

$ npm install express-simple-sitemap

or

$ yarn add express-simple-sitemap

Usage

// express setup
const express = require('express');
const app = express();

// import express-simple-sitemap
const sitemap = require('express-simple-sitemap');

// add express-simple-sitemap as middleware
app.use(sitemap({
    sitemapUrl: '/sitemap.xml', // optional, default value is '/sitemap.xml'
    urls: [
        {
            url: 'https://github.com/jenbuzz',
            lastmod: '2018-12-08', // optional
            changefreq: 'daily', // optional
            priority: 1.0, // optional
        },
        {
            url: 'https://github.com/jenbuzz/express-simple-sitemap',
        },
    ]
}));

Output:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>https://github.com/jenbuzz</loc>
        <lastmod>2018-12-08</lastmod>
        <changefreq>daily</changefreq>
        <priority>1</priority>
    </url>
    <url>
        <loc>https://github.com/jenbuzz/express-simple-sitemap</loc>
    </url>
</urlset>

License

This package is open-sourced software licensed under the MIT license