Approach Question

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

β”œβ”€β”€ posts/
β”‚   β”œβ”€β”€
β”‚   └──
β”œβ”€β”€ quotes/
β”‚   β”œβ”€β”€ quote-1/
β”‚   β”‚   β”œβ”€β”€ cover.jpg
β”‚   β”‚   └──
β”‚   β”œβ”€β”€ quote-2/
β”‚   β”‚   β”œβ”€β”€ cover.jpg
β”‚   β”‚   └──
β”‚   └──


title = 'Quotes'
date = 2023-04-28T10:30:15-07:00
draft = false
list = 'never'
publishResources = true
render = 'never'


{{< 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.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.