Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zerostaticthemes/hugo-serif-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Pettersson <petterssonjoel@gmail.com>2022-08-17 08:54:39 +0300
committerJoel Pettersson <petterssonjoel@gmail.com>2022-08-17 08:54:39 +0300
commitfa2c1af881bc2fbc36eb382eadce4f3148c941ad (patch)
tree070cdcb04d1f5ccbb456cc036a80ed0a03eaa93d
parent41ee32b40dd9ec193b3f9230cc05dee36580a91b (diff)
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.
-rw-r--r--layouts/_default/summary.html2
-rw-r--r--layouts/services/summary.html2
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 @@
<div class="summary">
<h2>
- <a href="{{ .Permalink }}">{{ .Title }}</a>
+ <a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h2>
{{ .Content | truncate 120 "…" }}
</div>
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 @@
<div class="service service-summary">
<div class="service-content">
<h2 class="service-title">
- <a href="{{ .Permalink }}">{{ .Title }}</a>
+ <a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h2>
<p>{{ .Content | plainify | htmlUnescape | truncate 120 "…" }}</p>
</div>