From: Mischa POSLAWSKY Date: Wed, 27 Dec 2023 18:06:50 +0000 (+0100) Subject: common: preferred external url in canonical link X-Git-Url: http://git.shiar.net/sheet.git/commitdiff_plain/9e4974683459036041b339e6576f6d9e2e48edaa common: preferred external url in canonical link Coalesce similar or identical pages in (Google) search results and rankings. Without further cleanup, the requested paths seem a sufficient target for all pages except for charset (significant option to be maintained) and keyboard (legacy shorthands). --- diff --git a/charset.plp b/charset.plp index 33f02c7..bbab1d6 100644 --- a/charset.plp +++ b/charset.plp @@ -6,6 +6,7 @@ my @tablist = split m{/+}, $Request || 'default'; Html({ title => 'charset cheat sheet', version => '1.3', + canonical => "/charset/$Request" . ($mode && '?compare'), description => [ "Reference sheet with all glyphs in common character encoding tables,", "and an overview of Unicode ranges and UTF-8 bytes.", diff --git a/common.inc.plp b/common.inc.plp index 6295de7..9d34128 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -157,6 +157,11 @@ sub Html { my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x; + if (my $url = $meta->{canonical} // "/$file/$Request") { + $url = "https://sheet.shiar.nl$url"; + push @{ $meta->{raw} }, qq(); + } + PLP_START { # leading output say ''; diff --git a/keyboard.plp b/keyboard.plp index 62e150a..e4ba72d 100644 --- a/keyboard.plp +++ b/keyboard.plp @@ -26,6 +26,7 @@ if ($Request =~ /^altgr/ and open my $cssinc, '<', 'keyboard/altgr.css') { Html({ title => "\L$mode\E keyboard cheat sheet", version => $info->{version} || '0.1', + canonical => -e "$Request.plp" ? "/$Request" : undef, # historic shorthand description => $info->{description} // ["Keyboard cheat sheet for the default controls of $mode."], keywords => [@{ $info->{keywords} // [] }, qw'