diff --git a/man/crystal.1 b/man/crystal.1 index c13644503021..56af04ebdf40 100644 --- a/man/crystal.1 +++ b/man/crystal.1 @@ -208,6 +208,8 @@ line number If this option is missing and can't be automatically determined, the generator can't produce source code links. .It Fl o Ar DIR, Fl -output Ar DIR Set the output directory (default: ./docs). +.It Fl b Ar URL, Fl -canonical-base-url Ar URL +Indicate the preferred URL with rel="canonical" link element. .It Fl b Ar URL, Fl -sitemap-base-url Ar URL Set the sitemap base URL. Sitemap will only be generated when this option is set. .It Fl -sitemap-priority Ar PRIO diff --git a/src/compiler/crystal/command/docs.cr b/src/compiler/crystal/command/docs.cr index 573bb3a4fc63..b17d652d5af9 100644 --- a/src/compiler/crystal/command/docs.cr +++ b/src/compiler/crystal/command/docs.cr @@ -56,8 +56,8 @@ class Crystal::Command project_info.json_config_url = value end - opts.on("--canonical-base-url=URL", "Deprecated option. Use --sitemap-base-url instead.") do |value| - abort "Option --canonical-base-url is no longer supported. Use --sitemap-base-url instead." + opts.on("--canonical-base-url=URL", %(Indicate the preferred URL with rel="canonical" link element)) do |value| + project_info.canonical_base_url = value end opts.on("--sitemap-base-url=URL", "-b URL", "Set the sitemap base URL and generates sitemap") do |value| diff --git a/src/compiler/crystal/tools/doc/html/_head.html b/src/compiler/crystal/tools/doc/html/_head.html index ed691f057bab..f4b7e2715498 100644 --- a/src/compiler/crystal/tools/doc/html/_head.html +++ b/src/compiler/crystal/tools/doc/html/_head.html @@ -7,5 +7,13 @@ <% end %> +<%- if canonical_base_url = project_info.canonical_base_url -%> + <%- if current_type = self.current_type -%> + + <%- else -%> + + <% end -%> +<% end -%> + diff --git a/src/compiler/crystal/tools/doc/html/main.html b/src/compiler/crystal/tools/doc/html/main.html index bf669a247638..5a1118e957e1 100644 --- a/src/compiler/crystal/tools/doc/html/main.html +++ b/src/compiler/crystal/tools/doc/html/main.html @@ -1,7 +1,7 @@
- <%= HeadTemplate.new(project_info, "") %> + <%= HeadTemplate.new(project_info, nil) %>