Skip to content

Sitemap Generation

When using GitHub Pages, a sitemap is only created when using a Jekyll theme. For all other static site generators, a GitHub Actions script is required to build the XML file.

file nane: sitemap.xml

name: Generate xml sitemap
on:
push:
branches: [ main ]
jobs:
sitemap_job:
runs-on: ubuntu-latest
name: Generate a sitemap
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate the sitemap
id: sitemap
uses: cicirello/generate-sitemap@v1
with:
base-url-path: https://THE.URL.TO.YOUR.PAGE/
- name: Output stats
run: |
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}"

This xml script needs to be added into each Repo you are working with.

After generating the sitemap, and testing that it displays correctly on your published site, submit it to the Google Search Console website, by navigating to the Sitemaps section and entering the filename (e.g., sitemap.xml).