From ea7b89ea2be63107968d921c4f00e925836c2861 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 22 Oct 2020 18:18:24 +0200 Subject: [PATCH 1/5] inline side-menu include It was fully static, only used in a single place, but would be processed for each page. Signed-off-by: Sebastiaan van Stijn --- _includes/body.html | 12 ++++++++++-- _includes/side-menu.html | 4 ---- 2 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 _includes/side-menu.html diff --git a/_includes/body.html b/_includes/body.html index db8f03ec6e..19e7835cf8 100644 --- a/_includes/body.html +++ b/_includes/body.html @@ -19,7 +19,12 @@ {%- if page.advisory -%}
{{ site.data.advisories.texts[page.advisory] | markdownify }}
{%- endif -%} - {%- unless page.skip_read_time == true -%}{% include read_time.html %}{%- endunless -%} + {%- unless page.skip_read_time == true -%} + {%- assign words = content | number_of_words -%} + {%- if words >= 360 -%} +

Estimated reading time: {{ words | divided_by:180 }} minutes

+ {%- endif -%} + {%- endunless -%} {{ content }} {%- unless page.notags == true -%} {%- assign keywords = page.keywords | split:"," -%} @@ -40,7 +45,10 @@
diff --git a/_includes/side-menu.html b/_includes/side-menu.html deleted file mode 100644 index bd78ba6a7c..0000000000 --- a/_includes/side-menu.html +++ /dev/null @@ -1,4 +0,0 @@ - From 9b79a27ab49a98db4e1839d7e73564f3efae3d85 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Oct 2020 00:58:54 +0200 Subject: [PATCH 2/5] Dockerfile: output Jekyll profile information Also skip updating sitemap.xml for the development environment. Signed-off-by: Sebastiaan van Stijn --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b9fb2bd99..ab80d3bd1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,14 +57,14 @@ COPY --from=upstream-resources /usr/src/app/md_source/. ./ RUN ./_scripts/update-api-toc.sh ARG JEKYLL_ENV RUN echo "Building docs for ${JEKYLL_ENV} environment" -RUN set -eux; \ +RUN set -eu; \ if [ "${JEKYLL_ENV}" = "production" ]; then \ - jekyll build -d ${TARGET} --config _config.yml,_config_production.yml; \ + jekyll build --profile -d ${TARGET} --config _config.yml,_config_production.yml; \ + sed -i 's#/#https://docs.docker.com/#' "${TARGET}/sitemap.xml"; \ else \ - jekyll build -d ${TARGET}; \ + jekyll build --profile -d ${TARGET}; \ fi; \ - find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#\(]* href="\)https://docs.docker.com/#\1/#g' "$i"; done; \ - sed -i 's#/#https://docs.docker.com/#' "${TARGET}/sitemap.xml"; + find ${TARGET} -type f -name '*.html' | while read i; do sed -i 's#\(]* href="\)https://docs.docker.com/#\1/#g' "$i"; done; # This stage only contains the generated files. It can be used to host the From 2fe7e6106a3a57a9fdf440f22972b045a286e12d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Oct 2020 01:04:16 +0200 Subject: [PATCH 3/5] Optimize configuration to reduce build-times - remove wildcard match for defaults (this caused a ripple effect and slowed down total build time with 60 seconds?) - skip generating metadata.json (which took 25+ seconds) - skip generating sitemap.xml (10+ seconds) Build-times before/after: Production before: 132 seconds Production after: 62 seconds Development before: 121 seconds Development after: 35 seconds Signed-off-by: Sebastiaan van Stijn --- _config.yml | 108 ++++++++++++----------------------------- _config_production.yml | 103 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 132 insertions(+), 79 deletions(-) diff --git a/_config.yml b/_config.yml index 9e285d14aa..7fecfb4453 100644 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,8 @@ +## +# Default configuration file +# +# This file overrides options set in _config.yml for production / deploy +## name: Docker Documentation markdown: kramdown kramdown: @@ -11,11 +16,10 @@ incremental: true permalink: pretty safe: false lsi: false -exclude: ["_samples", "_scripts", "404.html", "datacenter", "ee", "index.html"] +exclude: ["_samples", "_scripts", "404.html", "datacenter", "ee", "index.html", "js/metadata.json"] # Component versions -- address like site.docker_ce_version # You can't have - characters in these for non-YAML reasons - latest_engine_api_version: "1.40" docker_ce_version: "19.03" compose_version: "1.27.4" @@ -24,15 +28,34 @@ compose_file_v2: "2.4" machine_version: "0.16.0" distribution_version: "2.7" -collections: - samples: - output: true - +# List of plugins to enable for local development builds. Mostly the same as +# for production, but without the "jekyll-sitemap" plugin, which is not needed +# for previewing, and excluding saves some time to build plugins: - jekyll-redirect-from - jekyll-relative-links - - jekyll-sitemap +# Assets +# +# We specify the directory for Jekyll so we can use @imports. +# +# For local development, we build css with the "expanded" format to produce +# human-readable output for easier debugging. +sass: + sass_dir: _scss + style: expanded + +# Set default options / metadata for some paths. +# +# Setting options here prevents having to repeat the same option in front-matter +# on every page. Avoid using wildcards, such as "path: engine/api/v1.*", as +# limitations in Jekyll cause those to introduce a _severe_ impact on build-time, +# affecting generation of (e.g.) sitemap.xml and metadata.json, resulting in the +# total build to take 60 seconds longer to build (!). +# +# The list below is for "development" (local builds, and PR previews) builds only, +# and should be kept minimal to allow for fast builds. Other options should go +# into _config_production.yml, which is used for production deploys. defaults: - scope: path: "" @@ -42,78 +65,7 @@ defaults: toc_min: 2 toc_max: 3 - # Set the correct edit-URL for upstream resources. We usually don't create a direct - # edit link for these, and instead point to the directory that contains the file. - - scope: - path: engine/api/v1.* - values: - edit_url: "https://github.com/docker/docker/tree/master/docs/api" - - scope: - path: engine/deprecated - values: - edit_url: "https://github.com/docker/cli/tree/master/docs/" - - scope: - path: engine/extend - values: - edit_url: "https://github.com/docker/cli/tree/master/docs/extend" - - scope: - path: engine/reference - values: - edit_url: "https://github.com/docker/cli/tree/master/docs/reference" - scope: path: engine/reference/commandline values: - edit_url: "https://github.com/docker/cli/tree/master/docs/reference/commandline" skip_read_time: true - - scope: - path: glossary - values: - edit_url: "https://github.com/docker/docker.github.io/blob/master/_data/glossary.yaml" - - scope: - path: notary/reference - values: - edit_url: "https://github.com/theupdateframework/notary/tree/master/docs/reference" - - scope: - path: registry/configuration - values: - edit_url: "https://github.com/docker/distribution/tree/master/docs" - - scope: - path: registry/spec - values: - edit_url: "https://github.com/docker/distribution/tree/master/docs/spec" - - scope: - path: compliance - values: - edit_url: "https://github.com/mirantis/compliance/tree/master/docs/compliance" - - # Hide Enterprise content from sitemap. These directories still contains stubs - # that are needed to redirect old URLs - - scope: - path: "datacenter" - values: - sitemap: false - title: Docker Enterprise moved to Mirantis - - scope: - path: "desktop/enterprise" - values: - sitemap: false - - scope: - path: "ee" - values: - sitemap: false - title: Docker Enterprise moved to Mirantis - - scope: - path: "machine" - values: - sitemap: false - - scope: - path: "samples/library" - values: - sitemap: false - -# Assets -# -# We specify the directory for Jekyll so we can use @imports. -sass: - sass_dir: _scss - style: expanded diff --git a/_config_production.yml b/_config_production.yml index 9b95b00f82..71664640e0 100644 --- a/_config_production.yml +++ b/_config_production.yml @@ -1,11 +1,112 @@ +## +# This file overrides options set in _config.yml for production / deploy +## -# Include files that are excluded in "development" ("enterprise" stubs) for production +# Override the exclusion list to include files that are excluded in "development", +# such as the "enterprise" stubs, which are in place to facilitate redirects +# to Mirantis. exclude: ["_scripts", "404.html", "index.html"] # Google Analytics, etc. google_analytics: GTM-WL2QLG5 polldaddy_id: 8453675 +plugins: + - jekyll-redirect-from + - jekyll-relative-links + - jekyll-sitemap + # Assets +# +# For production/deploy, we build css with the "compressed" format, to produce +# smaller files. sass: style: compressed + +collections: + samples: + output: true + +# Set default options / metadata for some paths. +# +# Setting options here prevents having to repeat the same option in front-matter +# on every page. Avoid using wildcards, such as "path: engine/api/v1.*", as +# limitations in Jekyll cause those to introduce a _severe_ impact on build-time, +# affecting generation of (e.g.) sitemap.xml and metadata.json, resulting in the +# total build to take 60 seconds longer to build (!). +# +# The list below is used for *production* deploys, and overrides the one defined +# in "_config.yml", which is used for local builds and pull-request previews. +defaults: + - scope: + path: "" + type: "pages" + values: + layout: docs + toc_min: 2 + toc_max: 3 + + # Set the correct edit-URL for upstream resources. We usually don't create a direct + # edit link for these, and instead point to the directory that contains the file. + - scope: + path: engine/deprecated.md + values: + edit_url: "https://github.com/docker/cli/tree/master/docs/" + - scope: + path: engine/extend.md + values: + edit_url: "https://github.com/docker/cli/tree/master/docs/extend" + - scope: + path: engine/reference + values: + edit_url: "https://github.com/docker/cli/tree/master/docs/reference" + - scope: + path: engine/reference/commandline + values: + edit_url: "https://github.com/docker/cli/tree/master/docs/reference/commandline" + skip_read_time: true + - scope: + path: glossary.md + values: + edit_url: "https://github.com/docker/docker.github.io/blob/master/_data/glossary.yaml" + - scope: + path: notary/reference + values: + edit_url: "https://github.com/theupdateframework/notary/tree/master/docs/reference" + - scope: + path: registry/configuration + values: + edit_url: "https://github.com/docker/distribution/tree/master/docs" + - scope: + path: registry/spec + values: + edit_url: "https://github.com/docker/distribution/tree/master/docs/spec" + - scope: + path: compliance + values: + edit_url: "https://github.com/mirantis/compliance/tree/master/docs/compliance" + + # Hide Enterprise content from sitemap. These directories still contains stubs + # that are needed to redirect old URLs + - scope: + path: "datacenter" + values: + sitemap: false + title: Docker Enterprise moved to Mirantis + - scope: + path: "desktop/enterprise" + values: + sitemap: false + - scope: + path: "ee" + values: + sitemap: false + title: Docker Enterprise moved to Mirantis + - scope: + path: "machine" + values: + sitemap: false + - scope: + path: "samples/library" + values: + sitemap: false From 87f40087d8fca8b981fae77ea38c48a5b90d9d6f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Oct 2020 13:03:10 +0200 Subject: [PATCH 4/5] remove docs.html layout before renaming / move body Signed-off-by: Sebastiaan van Stijn --- _layouts/docs.html | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100755 _layouts/docs.html diff --git a/_layouts/docs.html b/_layouts/docs.html deleted file mode 100755 index f68f39ecca..0000000000 --- a/_layouts/docs.html +++ /dev/null @@ -1,10 +0,0 @@ - - - -{%- include head.html -%} -{%- if page.landing == true -%} - {%- include body-landing.html -%} -{%- else -%} - {%- include body.html -%} -{%- endif -%} - From d8836211452a1214f874ae4509dd7f637c7f742a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 23 Oct 2020 13:14:38 +0200 Subject: [PATCH 5/5] inline "body-landing" and "body" into layout This reduces the time to build, as Jekyll doesn't have to render the body, then copy it into the layout: Production before: 62 seconds Production after: 46 seconds Development before: 35 seconds Development after: 33 seconds Signed-off-by: Sebastiaan van Stijn --- _includes/body.html => _layouts/docs.html | 7 ++++++- _includes/body-landing.html => _layouts/landing.html | 0 index.md | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) rename _includes/body.html => _layouts/docs.html (97%) rename _includes/body-landing.html => _layouts/landing.html (100%) diff --git a/_includes/body.html b/_layouts/docs.html similarity index 97% rename from _includes/body.html rename to _layouts/docs.html index 19e7835cf8..9ebb80d267 100644 --- a/_includes/body.html +++ b/_layouts/docs.html @@ -1,8 +1,12 @@ + + + +{%- include head.html -%}
{% include header.html %} @@ -83,3 +87,4 @@ {%- if jekyll.environment == 'production' -%}{%- include analytics/polldaddy.html -%}{%- endif -%} + diff --git a/_includes/body-landing.html b/_layouts/landing.html similarity index 100% rename from _includes/body-landing.html rename to _layouts/landing.html diff --git a/index.md b/index.md index b788109b2d..3ec9ccfc8d 100644 --- a/index.md +++ b/index.md @@ -1,7 +1,7 @@ --- description: Home page for Docker's documentation keywords: Docker, documentation, manual, guide, reference, api, samples -landing: true +layout: landing title: Docker Documentation notoc: true notags: true