Hello,
I want to implement link shortcode, which renders page title link with description front matter, but I could not find out any way to achieve it. any suggestions would be appreciated.
Thanks,
Ashish
Hello,
I want to implement link shortcode, which renders page title link with description front matter, but I could not find out any way to achieve it. any suggestions would be appreciated.
Thanks,
Ashish
Post your question in Support not in Tips & tricks if you want someone to respond…
I have created below shortcode:
<section class="related">
<h2>Related:</h2>
<ul>
{{ range .Params }}{{ with $.Site.GetPage . }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<p>{{ .Description | markdownify }}</p>
</li>
{{ end }}{{ end }}
</ul>
and calling shortcode using below code, but It is not printing any post with description.
{{< descrtiptionLink "Post1" "Post2" >}}
Thats not how you access shortcode params look at the docs you need to use positional params: https://gohugo.io/templates/shortcode-templates/#access-parameters
Or a dict: https://gohugo.io/functions/dict/#readout
Hello benmarte,
how about this - https://gohugo.io/templates/shortcode-templates/#params. this looks proper way, it looks I am missing something. Basically I am trying to modify code from this ticket to fill my requirement. I modified a bit to show Description from target link (md) file.
Hi,
Your snippet works for me. Do you have your site code somewhere we can have a look at? Have a read about Requesting Help to see what information we need from you to be able to help you better.