From fa2c1af881bc2fbc36eb382eadce4f3148c941ad Mon Sep 17 00:00:00 2001 From: Joel Pettersson Date: Tue, 16 Aug 2022 22:54:39 -0700 Subject: Avoid summary link target issue when deployed to CloudFlare pages From https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site/#deploying-with-cloudflare-pages: Hugo allows you to configure the baseURL of your application. This allows you to utilize the absURL helper to construct full canonical URLs. In order to do this with Pages, you must provde the -b or --baseURL flags with the CF_PAGES_URL environment variable to your hugo build command. Using the advice above, the baseURL is set to the specific deployment URL by CloudFlare, e.g. https://848e759b.my-project-name-here.pages.dev. Let's say now that 848e759b is the most recent production build. That means the same version is available at my-project-name-here.pages.dev. Now, when visiting https://my-project-name-here.pages.dev/, however, the target for any link using `{{ .Permalink }}` will point to https://848e759b.my-project-name-here.pages.dev instead of https://my-project-name-here.pages.dev/. By using the relative permalink instead, the issues is avoided altogether. --- layouts/_default/summary.html | 2 +- layouts/services/summary.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 5f9a9e9..4ce4f2a 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -1,6 +1,6 @@

- {{ .Title }} + {{ .Title }}

{{ .Content | truncate 120 "…" }}
diff --git a/layouts/services/summary.html b/layouts/services/summary.html index 57d46ee..bccd45e 100644 --- a/layouts/services/summary.html +++ b/layouts/services/summary.html @@ -1,7 +1,7 @@

- {{ .Title }} + {{ .Title }}

{{ .Content | plainify | htmlUnescape | truncate 120 "…" }}

-- cgit v1.2.3