Use absolute URLs in sitemap.xml

We generate the website with relative URLs to allow hosting the content
on preview domains.

However, the sitemap.xml should always contain absolute URLs (including
the domain name).

I couldn't find a way to configure the sitemap URL's separately, so using
the same hack we use for stripping URL's in the HTML.

Before this, the sitemap.xml would contain;

    <url>
        <loc>/engine/reference/commandline/volume_prune/</loc>
    </url>

After this, the full URL is included

    <url>
        <loc>https://docs.docker.com/engine/reference/commandline/volume_prune/</loc>
    </url>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-09-25 17:45:17 +02:00
parent 463d98bd41
commit 29546c24f3
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 2 additions and 1 deletions

View File

@ -54,7 +54,8 @@ COPY --from=upstream-resources /usr/src/app/md_source/. ./
# API docs, based on the latest_engine_api_version parameter in _config.yml
RUN ./_scripts/update-api-toc.sh
RUN jekyll build -d ${TARGET} \
&& find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#href="https://docs.docker.com/#href="/#g' "$i"; done
&& find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#href="https://docs.docker.com/#href="/#g' "$i"; done \
&& sed -i 's#<loc>/#<loc>https://docs.docker.com/#' "${TARGET}/sitemap.xml"
# This stage only contains the generated files. It can be used to host the