Replacement for Hugo shortcodes

So I think the answer to this is a custom plugin/Kirbytag, but I’m not sure how to put it together and use it. I’m looking to duplicate Hugo’s shortcode functionality in Kirby, such that I can enter the tag in the post content and have it expanded behind the scenes. As an example from my Tufte theme, the epigraph code:


<div class="epigraph">
	<blockquote>
		{{ $t := .Get "type" }}
		{{ if eq $t "compact"  }}{{ .Inner | markdownify }}{{ else }}<p>{{ .Inner | markdownify }}</p>{{ end }}
		{{ if .IsNamedParams }}
			<footer>
				{{ with .Get "pre" }}{{ . }}{{ end }}
{{ with .Get "link" | safeURL | markdownify }}<a href={{ . }} target="_blank" rel="noopener">{{ end }}
				{{ with .Get "cite" }}<cite>{{ . }}</cite>{{ end }}
				{{ if .Get "link"}}</a>{{ end }}
				{{ with .Get "post" }}{{ . }}{{ end }}
			</footer>
		{{ end }}
	</blockquote>
</div>

This is what gets produced from the following shortcode syntax within the post itself:


{{< epigraph pre="Person's Name" cite="Site Name" link="//example.com/link/" >}}blockquote text goes here{{< /epigraph >}}

Where and how do I create the Kirby equivalent for this, and deploy it within blog post content? I think once I’ve gotten one of these down, the rest should be straightforward.

Forgive my still noob-ness. :wink:

(Edit: And yes, there’s a higher than zero percent chance I’m planning on porting Tufte to Kirby.)

The equivalent are indeed Kirbytags, you create them in a plugin, see docs: KirbyTags | Kirby CMS.

Some examples of custom Kirbytags: getkirby.com/site/plugins/site/extensions/tags.php at main · getkirby/getkirby.com · GitHub

The built-in KirbyTags might also help as a starting point: kirby/config/tags.php at main · getkirby/kirby · GitHub.

Thanks, Sonja. Glad to know I’m on the right track, and I appreciate the links so I can try and learn this myself. Some of what I learned in my PHP course from first year college is coming back to me, but if I get stuck I’ll check back here.