Skip to content

Commit cafd5a9

Browse files
committed
Use full URLs for canonical links
Canonical links are expected to be full URLs, not relative. For this to work, the Dockerfile had to be updated, because we're stripping the domain-name from links ("<a href..."), but the script currently also included "<link rel='canonical' .." tags. With the change, canonical links are left alone; These hrefs will be replaced echo '<a class=foo href="https://docs.docker.com/foo">hello</a>' | sed -e 's#\(<a[^>]* href="\)https://docs.docker.com/#\1/#g' # <a class=foo href="/foo">hello</a> echo '<a href="https://docs.docker.com/foo">hello</a>' | sed -e 's#\(<a[^>]* href="\)https://docs.docker.com/#\1/#g' # <a href="/foo">hello</a> But, for example, this one is left alone echo '<link rel="canonical" href="https://docs.docker.com/foo/bar" />' | sed -e 's#\(<a[^>]* href="?\)https://docs.docker.com/#\1/#g' # <link rel="canonical" href="https://docs.docker.com/foo/bar" /> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 393d3f6 commit cafd5a9

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ COPY --from=upstream-resources /usr/src/app/md_source/. ./
5454
# API docs, based on the latest_engine_api_version parameter in _config.yml
5555
RUN ./_scripts/update-api-toc.sh
5656
RUN jekyll build -d ${TARGET} \
57-
&& find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#href="https://docs.docker.com/#href="/#g' "$i"; done \
57+
&& find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#\(<a[^>]* href="\)https://docs.docker.com/#\1/#g' "$i"; done \
5858
&& sed -i 's#<loc>/#<loc>https://docs.docker.com/#' "${TARGET}/sitemap.xml"
5959

6060

_includes/head.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<title>{{ page.title | default: page_title }} | Docker Documentation</title>
3434
<meta name="description" content="{{ page.description | default: page_description | escape}}" />
3535
<meta name="keywords" content="{{ page.keywords | default: 'docker, docker open source, docker platform, distributed applications, microservices, containers, docker containers, docker software, docker virtualization' }}">
36-
<link rel="canonical" href="{{ page.url }}" />
36+
<link rel="canonical" href="https://docs.docker.com{{ page.url }}" />
3737

3838
<!-- favicon -->
3939
<link rel="icon" type="image/x-icon" href="/favicons/[email protected]" sizes="129x128">

_layouts/engine-api.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<link rel="icon" type="image/x-icon" href="/favicons/[email protected]" sizes="129x128" />
1414
<link rel="stylesheet" type="text/css" href="/css/api-reference.css" />
1515
<!-- make the latest API version the canonical page as that's what we want users to be using mostly -->
16-
<link rel="canonical" href="/engine/api/v{{ site.latest_engine_api_version }}/" />
16+
<link rel="canonical" href="https://docs.docker.com/engine/api/v{{ site.latest_engine_api_version }}/" />
1717
</head>
1818
<body>
1919
<redoc spec-url="/engine/api/{{ page.name | replace: '.md'}}.yaml" hide-hostname="true" suppress-warnings="true" lazy-rendering></redoc>

_layouts/redirect.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en-US">
33
<meta charset="utf-8">
44
<title>Redirecting&hellip;</title>
5-
<link rel="canonical" href="{{ page.redirect.to }}">
5+
<link rel="canonical" href="https://docs.docker.com{{ page.redirect.to }}">
66
<meta http-equiv="refresh" content="0; url={{ page.redirect.to }}">
77
<meta name="robots" content="noindex">
88
<h1>Redirecting&hellip;</h1>

0 commit comments

Comments
 (0)