| name | fix-external-links |
| description | Find and fix broken external links in the docs site using linkchecker |
Fix broken external links
Find and fix all broken external links in the docs site.
Steps
-
Fetch the latest release tag for the docs container image:
az acr repository show-tags \
--name gsoci \
--repository giantswarm/docs \
--orderby time_desc \
--output tsv | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -1
-
Store the tag as the TAG environment variable.
-
Start the docs server:
docker run -d --rm --name server -p 8080:8080 -P gsoci.azurecr.io/giantswarm/docs:$TAG
-
Run linkchecker with external link checking enabled:
docker run --rm --name linkchecker \
-v $PWD:/workdir \
-w /workdir \
--link server:server \
ghcr.io/linkchecker/linkchecker:latest \
http://server:8080 \
-t 3 \
--no-status \
--check-extern \
--file-output text/linkcheck-report.txt \
--ignore-url="^https://docs\.giantswarm\.io/.*" \
--ignore-url="^http://server:8080/changes/.*" \
--ignore-url="^https://.*example\.com/.*" \
--ignore-url=".*gigantic\.io.*" \
--ignore-url="^https://my-org\.github\.com/.*" \
--ignore-url="^https://github\.com/giantswarm/giantswarm/.*"
-
Read linkcheck-report.txt. Each link report starts with the term URL and ends with a double line break.
-
Analyse each reported link. Skip any:
- Internal links
- Non-permanent redirects (HTTP 302) within the same domain
- Links to
example.com
- Server errors (HTTP 5xx)
- Timeout errors
-
Fix permanent redirects (HTTP 301) — update the URL in the markdown source to point directly to the real target URL ("Real URL" in the report).
-
For 404 not found errors — search the web for an adequate replacement page. If found, update the link. If not found, leave the link unchanged and note it.
-
Stop the server:
docker kill server
-
Report results to the user as Markdown suitable for a GitHub pull request description, in this order:
- List of redirects fixed
- List of 404 errors fixed
- List of 404 errors not fixed (no replacement found)
- List of links skipped
- Statistical summary (warnings/errors reported, links modified, links unmodified)