Hi there,
I have a blog under my /content folder and within the blog, but also within my other contents i want to be able to display quotes.
Therefore I would prefer to have one place to store all quotes which have something like the quote, a picture and some other fields.
I do not want those quotes to be accessible directly, so they should have no page which displays just one quote or an overview page, but i want them to be useable within my blog and other content areas.
There I will probably integrate them via a shortcode.
What is the best way to achieve this?
best regard
Armin
content/
βββ posts/
β βββ post-1.md
β βββ post-2.md
βββ quotes/
β βββ quote-1/
β β βββ cover.jpg
β β βββ index.md
β βββ quote-2/
β β βββ cover.jpg
β β βββ index.md
β βββ _index.md
βββ _index.md
content/quotes/_index.md
+++
title = 'Quotes'
date = 2023-04-28T10:30:15-07:00
draft = false
[cascade._build]
list = 'never'
publishResources = true
render = 'never'
+++
https://gohugo.io/content-management/build-options/
markdown
{{< quotation quote-1 >}}
layouts/shortcodes/quotation.html (something likeβ¦)
{{ $quote := .Get 0 }}
{{ with $quote }}
{{ with site.GetPage (printf "quotes/%s" .) }}
<p>{{ .Title }}</p>
{{ with .Resources.GetMatch "cover.*" }}
{{ with .Resize "300x webp" }}
<p><img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt=""></p>
{{ end }}
{{ end }}
{{ .Content }}
{{ else }}
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name $quote $.Position }}
{{ end }}
{{ else }}
{{ errorf "The %q shortcode requires a single positional paramter. See %s" $.Name $.Position }}
{{ end }}
Thank you - exactly what I was searching for. Will give this tomorrow a try
Thanks again, works like a charm - I am not using the shortcode, as I solve it a bit different, but the principle is the same and with that knowledge I might rework some other parts as well, so that I can easily put out parts of my contents easier on other parts of the website.