mirror of https://github.com/docker/docs.git
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 <github@gone.nl>
This commit is contained in:
parent
393d3f6566
commit
cafd5a9943
|
@ -54,7 +54,7 @@ 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#\(<a[^>]* href="\)https://docs.docker.com/#\1/#g' "$i"; done \
|
||||
&& sed -i 's#<loc>/#<loc>https://docs.docker.com/#' "${TARGET}/sitemap.xml"
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<title>{{ page.title | default: page_title }} | Docker Documentation</title>
|
||||
<meta name="description" content="{{ page.description | default: page_description | escape}}" />
|
||||
<meta name="keywords" content="{{ page.keywords | default: 'docker, docker open source, docker platform, distributed applications, microservices, containers, docker containers, docker software, docker virtualization' }}">
|
||||
<link rel="canonical" href="{{ page.url }}" />
|
||||
<link rel="canonical" href="https://docs.docker.com{{ page.url }}" />
|
||||
|
||||
<!-- favicon -->
|
||||
<link rel="icon" type="image/x-icon" href="/favicons/docs@2x.ico" sizes="129x128">
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<link rel="icon" type="image/x-icon" href="/favicons/docs@2x.ico" sizes="129x128" />
|
||||
<link rel="stylesheet" type="text/css" href="/css/api-reference.css" />
|
||||
<!-- make the latest API version the canonical page as that's what we want users to be using mostly -->
|
||||
<link rel="canonical" href="/engine/api/v{{ site.latest_engine_api_version }}/" />
|
||||
<link rel="canonical" href="https://docs.docker.com/engine/api/v{{ site.latest_engine_api_version }}/" />
|
||||
</head>
|
||||
<body>
|
||||
<redoc spec-url="/engine/api/{{ page.name | replace: '.md'}}.yaml" hide-hostname="true" suppress-warnings="true" lazy-rendering></redoc>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="en-US">
|
||||
<meta charset="utf-8">
|
||||
<title>Redirecting…</title>
|
||||
<link rel="canonical" href="{{ page.redirect.to }}">
|
||||
<link rel="canonical" href="https://docs.docker.com{{ page.redirect.to }}">
|
||||
<meta http-equiv="refresh" content="0; url={{ page.redirect.to }}">
|
||||
<meta name="robots" content="noindex">
|
||||
<h1>Redirecting…</h1>
|
||||
|
|
Loading…
Reference in New Issue