From d930502a550dd838a1a93368c91fc566a9ef1d4e Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 3 Nov 2018 23:42:15 +0000 Subject: [PATCH] feat: add `preview_only` option for featured image Add `preview_only = true` under `[image]` in a page's front matter to only show featured image in page previews and not on the page itself. Example: https://raw.githubusercontent.com/gcushen/hugo-academic/master/exampleSite/content/post/getting-started/index.md Close #789 See #728 --- exampleSite/content/post/getting-started/index.md | 3 +++ layouts/partials/page_header.html | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/exampleSite/content/post/getting-started/index.md b/exampleSite/content/post/getting-started/index.md index 5b527ef8..b1dfb49e 100644 --- a/exampleSite/content/post/getting-started/index.md +++ b/exampleSite/content/post/getting-started/index.md @@ -30,6 +30,9 @@ summary = "Create a beautifully simple website or blog in under 10 minutes." # Options: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight focal_point = "" + # Show image only in page previews? + preview_only = false + # Set captions for image gallery. [[gallery_item]] diff --git a/layouts/partials/page_header.html b/layouts/partials/page_header.html index 91fb28d9..f80e84c0 100644 --- a/layouts/partials/page_header.html +++ b/layouts/partials/page_header.html @@ -29,14 +29,14 @@ {{end}} {{/* Featured image */}} -{{ with $featured }} -{{ $image := .Fill (printf "1600x400 q90 %s" $anchor) }} +{{ if and $featured (not $.Params.image.preview_only) }} +{{ $image := $featured.Fill (printf "1600x400 q90 %s" $anchor) }}
{{ with $.Params.image.caption }}{{ . | markdownify | emojify }}{{ end }}
-{{ $image := .Fill (printf "680x500 q90 %s" $anchor) }} +{{ $image := $featured.Fill (printf "680x500 q90 %s" $anchor) }}