From: Danilo M. Date: Sun, 5 Apr 2026 08:32:37 +0000 (+0200) Subject: fix: use excerpts instead of full content in article cards X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=36fffd8e8dfab639b835e5794b18267c146d231c;p=danix2-hugo-theme.git fix: use excerpts instead of full content in article cards Updated both home.html and section.html to: 1. Check for 'excerpt' field in front matter first 2. If excerpt exists, use it 3. If not, generate from content: get first paragraph, convert to plain text, truncate to 150 characters This prevents full article content from showing in feeds while respecting custom excerpts when provided. Applies to both homepage feed and articles section list view. Co-Authored-By: Claude Haiku 4.5 --- diff --git a/layouts/home.html b/layouts/home.html index cffb6bc..f285b41 100644 --- a/layouts/home.html +++ b/layouts/home.html @@ -12,7 +12,13 @@ {{ range first 6 $articles }} {{ $type := .Params.type }} {{ if not $type }}{{ $type = "article" }}{{ end }} - {{ $data := dict "title" .Title "type" $type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }} + + {{ $excerpt := .Params.excerpt }} + {{ if not $excerpt }} + {{ $excerpt = .Summary | plainify | truncate 150 }} + {{ end }} + + {{ $data := dict "title" .Title "type" $type "description" $excerpt "date" .Date "url" .RelPermalink "image" .Params.image "featured" .Params.featured }} {{ partial "post-card.html" $data }} {{ end }} {{ end }} diff --git a/layouts/section.html b/layouts/section.html index 8b938f3..b9f0646 100644 --- a/layouts/section.html +++ b/layouts/section.html @@ -14,7 +14,12 @@
{{ range .Pages.ByDate.Reverse }} - {{ $data := dict "title" .Title "type" .Params.type "description" .Summary "date" .Date "url" .RelPermalink "image" .Params.image "featured" false }} + {{ $excerpt := .Params.excerpt }} + {{ if not $excerpt }} + {{ $excerpt = .Summary | plainify | truncate 150 }} + {{ end }} + + {{ $data := dict "title" .Title "type" .Params.type "description" $excerpt "date" .Date "url" .RelPermalink "image" .Params.image "featured" false }} {{ partial "post-card.html" $data }} {{ end }}