Skip to content

SEO Sitemaps

This guide explains how to use the WhiteBeard News Suite API to fetch sitemap data and expose the following URLs on your frontend:

  • /sitemap_index.xml
  • /news-sitemap.xml
  • /section-sitemap.xml
  • /author-sitemap.xml
  • /article-sitemap{number}.xml

These endpoints will allow search engines to crawl your site effectively.


The following API paths are used to fetch the required sitemap data:

  • API Path: /publication/{publication_id}/content/sitemap/index.xml
  • Description: Fetches the sitemap index for a publication.
  • Response: Sitemap index in XML format.
  • HTTP Method: GET
  • API Path: /publication/{publication_id}/content/sitemap/news.xml
  • Description: Fetches the news sitemap for a publication.
  • Response: News sitemap in XML format.
  • HTTP Method: GET
  • API Path: /publication/{publication_id}/content/sitemap/categories.xml
  • Description: Fetches the section/category sitemap for a publication.
  • Response: Section sitemap in XML format.
  • HTTP Method: GET
  • API Path: /publication/{publication_id}/content/sitemap/sitemap{page_number}.xml
  • Description: Fetches a paginated sitemap of articles for a publication.
  • Response: Article sitemap in XML format.
  • HTTP Method: GET

Make sure to include an API-Key header. Refer to the Swagger docs to try out the API.


Ensure your frontend exposes the following URLs:

  • /sitemap_index.xml
  • /news-sitemap.xml
  • /section-sitemap.xml
  • /author-sitemap.xml
  • /article-sitemap{number}.xml

These URLs should act as proxies to fetch data from the API.


Use the API paths to fetch the required sitemap data. Below is an example implementation for each sitemap type.

import axios from 'axios';
export async function getSitemapIndex(publicationId) {
const response = await axios.get(`/publication/${publicationId}/content/sitemap/index.xml`, {
headers: {
'API-Key': 'your-api-key-here', // Replace with your actual API key
},
});
return response.data; // XML response
}
import axios from 'axios';
export async function getNewsSitemap(publicationId) {
const response = await axios.get(`/publication/${publicationId}/content/sitemap/news.xml`, {
headers: {
'API-Key': 'your-api-key-here', // Replace with your actual API key
},
});
return response.data; // XML response
}
import axios from 'axios';
export async function getSectionSitemap(publicationId) {
const response = await axios.get(`/publication/${publicationId}/content/sitemap/categories.xml`, {
headers: {
'API-Key': 'your-api-key-here', // Replace with your actual API key
},
});
return response.data; // XML response
}

Note that the authors site map currently lists all authors with a filled in “Department” name in the backend.

import axios from 'axios';
export async function getSectionSitemap(publicationId) {
const response = await axios.get(`/publication/${publicationId}/content/sitemap/authors.xml`, {
headers: {
'API-Key': 'your-api-key-here', // Replace with your actual API key
},
});
return response.data; // XML response
}
import axios from 'axios';
export async function getArticleSitemap(publicationId, pageNumber) {
const response = await axios.get(`/publication/${publicationId}/content/sitemap/sitemap${pageNumber}.xml`, {
headers: {
'API-Key': 'your-api-key-here', // Replace with your actual API key
},
});
return response.data; // XML response
}

Set up your backend or server to serve the sitemaps at the required URLs. For example:

import express from 'express';
import { getSitemapIndex, getNewsSitemap, getSectionSitemap, getArticleSitemap } from './sitemap_services';
const app = express();
const publicationId = 'your-publication-id'; // Replace with your publication ID
// Cache duration: 1 year (in seconds)
const CACHE_DURATION = 365 * 24 * 60 * 60;
app.get('/sitemap_index.xml', async (req, res) => {
const sitemap = await getSitemapIndex(publicationId);
res.set('Cache-Control', `public, max-age=${CACHE_DURATION}`).type('application/xml').send(sitemap);
});
app.get('/news-sitemap.xml', async (req, res) => {
const sitemap = await getNewsSitemap(publicationId);
res.set('Cache-Control', `public, max-age=${CACHE_DURATION}`).type('application/xml').send(sitemap);
});
app.get('/section-sitemap.xml', async (req, res) => {
const sitemap = await getSectionSitemap(publicationId);
res.set('Cache-Control', `public, max-age=${CACHE_DURATION}`).type('application/xml').send(sitemap);
});
app.get('/article-sitemap:pageNumber.xml', async (req, res) => {
const { pageNumber } = req.params;
const sitemap = await getArticleSitemap(publicationId, pageNumber);
res.set('Cache-Control', `public, max-age=${CACHE_DURATION}`).type('application/xml').send(sitemap);
});
app.listen(3000, () => console.log('Server running on port 3000'));

  1. Start your server and ensure the URLs are accessible:

    • http://localhost:3000/sitemap_index.xml
    • http://localhost:3000/news-sitemap.xml
    • http://localhost:3000/section-sitemap.xml
    • http://localhost:3000/article-sitemap1.xml
  2. Verify the XML responses match the expected format.

  3. Submit the URLs to search engines (e.g., Google Search Console) for indexing.


  1. Cache Headers: The Cache-Control header is set to cache the sitemap responses for 1 year (max-age=31536000). This ensures that the sitemaps are cached efficiently by Cloudflare. Make sure your Cloudflare cache rules are set to prevent browser caching.

  2. Proactive Purging: The CMS will proactively purge the sitemap URLs on your frontend whenever a related change occurs (e.g., new content, updated articles, or deleted sections). This ensures that the cached sitemaps are always up-to-date without requiring manual intervention.