Show Related pages in markdown content

Hi,

I have to show related pages, inside the content markdown. I have been using .Site.RegularPages.RelatedIndices to show related pages in templates. But now I need to show the related pages in the middle of the content markdown. There seems to be no way to use .Site.RegularPages.RelatedIndices in shortcodes. Please suggest how I can achieve this?

Thanks,
Aravind.

What’s the context? I need an example.

Maybe you’re trying to use something like .Site.RegularPages.RelatedIndices . "tags" "date" as a shortcode, where the problem is the . (context). See the documentation about it.

1 Like

If you use something like this within a template:

{{ $related := .Site.RegularPages.RelatedIndices . "tags" | first 5 }}

Then use something like this within a shortcode:

{{ $related := .Site.RegularPages.RelatedIndices .Page "tags" | first 5 }}

Like @sephore said, it’s all about the . (context).

4 Likes

Thank you @sephore @jmooring. As you mentioned problem is with context. It works fine.

1 Like

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