diff --git a/data/frontmatter.yaml b/data/frontmatter.yaml new file mode 100644 index 0000000000..723b17eaac --- /dev/null +++ b/data/frontmatter.yaml @@ -0,0 +1,18 @@ +# this file lets you add descriptions and keywords +# to files without modifying the file. +# +# Useful for upstream pages where we don't want to +# or can't add front matter to the source! +# +# To add descriptions and keywords for a page, +# add a key with the path of the page file, +# relative to the content directory. For upstream +# page files, that's the target of the file mount. + +engine/reference/builder.md: + description: | + Find all the available commands you can use in a Dockerfile + and learn how to use them, including COPY, ARG, ENTRYPOINT, and more. + keywords: | + dockerfile, docker file, docker copy, dockerfile exec, docker entrypoint, + dockerfile entrypoint, dockerfile arg, docker args, entrypoint, shell dockerfile diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 839ad14e30..993f6e54eb 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -1,5 +1,5 @@ {{ $title := partial "utils/title.html" . }} -{{ $description := .Description | default .Summary }} +{{ $description := partial "utils/description.html" . }} {{ if .IsHome }} {{ site.Title }} {{ else }} @@ -13,7 +13,7 @@ diff --git a/layouts/partials/utils/description.html b/layouts/partials/utils/description.html new file mode 100644 index 0000000000..c0e6aa086d --- /dev/null +++ b/layouts/partials/utils/description.html @@ -0,0 +1,14 @@ +{{ $desc := "" }} +{{ if .Description }} + {{ $desc = .Description }} +{{ else }} + {{ $desc = .Summary }} + {{ with .File }} + {{ with (index (site.Data.frontmatter) .Path) }} + {{ with .description }} + {{ $desc = strings.Replace . "\n" " " | strings.TrimRight " " }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} +{{ return $desc }} diff --git a/layouts/partials/utils/keywords.html b/layouts/partials/utils/keywords.html new file mode 100644 index 0000000000..754b0537b4 --- /dev/null +++ b/layouts/partials/utils/keywords.html @@ -0,0 +1,14 @@ +{{ $keywords := "" }} +{{ if .Keywords }} + {{ $keywords = .Keywords }} +{{ else }} + {{ $keywords = "docker, docker open source, docker platform, distributed applications, microservices, containers, docker containers, docker software, docker virtualization" }} + {{ with .File }} + {{ with (index (site.Data.frontmatter) .Path) }} + {{ with .keywords }} + {{ $keywords = strings.Replace . "\n" " " | strings.TrimRight " " }} + {{ end }} + {{ end }} + {{ end }} +{{ end }} +{{ return $keywords }} diff --git a/layouts/partials/utils/title.html b/layouts/partials/utils/title.html index 054dba2023..101b8baf1f 100644 --- a/layouts/partials/utils/title.html +++ b/layouts/partials/utils/title.html @@ -3,8 +3,13 @@ {{ $title = .LinkTitle }} {{ else }} {{ $title = index (findRE `# .*` .RawContent) 0 | strings.TrimLeft "# " }} - {{ if not $title }} - {{ with .File }} + {{ with .File }} + {{ with (index (site.Data.frontmatter) .Path) }} + {{ with .title }} + {{ $title = . }} + {{ end }} + {{ end }} + {{ if not $title }} {{ $title = strings.ReplaceRE "[-_]" " " .TranslationBaseName }} {{ end }} {{ end }}