⚑️ Sign up to Notaku
Notaku websites will expose a sitemap with all urls at /sitemap.xml.
This file is used for example by Google to index your content.

Exposing the sitemap when using a base path like /docs

If you are hosting the sitemap on a sub path like /docs you will need to add the urls from the /docs/sitemap.xml to your root sitemap

Example using Next.js

typescript
// pages/sitemap.xml.tsx import React from 'react' import { DOMParser } from 'xmldom' const paths = ['/', '/product/docs', '/product/blog'] const BASE = 'https://mysite.com' const parser = new DOMParser() class Sitemap extends React.Component { static async getInitialProps({ res }) { if (!res) { return } const myUrls = paths .map((relativeP) => { const u = new URL(relativeP, BASE).toString() return `<url><loc>${u}</loc></url>` }) .join('\n') const docsUrls = await getUrlsFromSitemap({ url: new URL('/docs/sitemap.xml', BASE).toString(), }) let sitemap = `<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> ${myUrls} ${docsUrls} </urlset> ` res.setHeader('Content-Type', 'text/xml') res.write(sitemap) res.end() } } async function getUrlsFromSitemap({ url }) { const docsSitemap = await ( await fetch(url, { headers: { accept: 'text/xml', }, }) ).text() const xml = parser.parseFromString(docsSitemap, 'text/xml') const urls = Array.from(xml.getElementsByTagName('loc')) .map((x) => x.textContent) .map((url) => { const u = new URL(new URL(url).pathname, BASE).toString() return `<url><loc>${u}</loc></url>` }) .join('\n') return urls } export default Sitemap
❗
If you are using the /blog path you will need to replace /docs with /blog in the code above
Then you will also need to add a robots.txt file in the public folder with the following content
plain text
User-agent: * Sitemap: https://mysite.com/sitemap.xml

Helpful?