Shortcode for link with page description


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.


Post your question in Support not in Tips & tricks if you want someone to respond…

1 Like

I have created below shortcode:

<section class="related">
    {{ range .Params }}{{ with $.Site.GetPage . }}
        <a href="{{ .Permalink }}">{{ .Title }}</a>
        <p>{{ .Description | markdownify }}</p>
    {{ end }}{{ end }}

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:

Or a dict:

Hello benmarte,

how about this - 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.


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.