[SOLVED] Shortcodes: Show partials in .md

Hey

I seem to be really struggling with getting an md file to include a partial.

At the moment, I have this in my .md file:

{{< incpartials p="test-partial.html" >}}

and in layouts/shortcodes/incpartials.html I have this:

{{ partial .Params.p }}

I am getting no errors in terminal but nothing is being outputted.

Any ideas?

If you want to call a partial test-partial.html from within a shortcode it can be done like:

test.md:

{{< incpartials >}}

layouts/shortcodes/incpartials.html:

{{ partial "test-partial.html" . }}

That’s the way I do it because you can not call a partial in an md file. Extremely flexible (at least for me). Might be other ways.

Hope this helps.

3 Likes

To add to @Leo_Merkel’s handy example, if you want to pass the partial name as an argument:

Usage:

{{< incpartials "test-partial.html" >}}

Definition:

{{ partial (.Get 0) . }}
4 Likes