Is it possible to embed partials in markdown?

Fairly new to all this and digging in. It seems that within templates it’s possible to pull in partials, but I can’t seem to find a way to do this within the content files? What’s the recommended way to handle duplicate content? It would be handy to be able to reference another content file and pull it in, like a partial.

Is this currently possible and I’m just not finding it?

Thanks!

You are looking for shortcodes. :slight_smile:

1 Like

Thanks for the reply, @maiki!

Shortcodes? That seems more for embedding things like images, videos, and the like. I’m trying to embed the contents of another markdown file. Or are you suggesting creating a custom shortcode to accomplish this?

Probably. You might check #tips-tricks to see if someone has already done that. But it isn’t difficult. You should try to create a shortcode to do what you want, because what you want has decisions that need to be made, such as if the content should be processed in someway, how front matter should render, etc.

Good luck! :slight_smile:

1 Like

@jasontheadams https://gohugo.io/templates/files/#use-readfile has what you need - an example custom shortcode for the readfile function.

1 Like

That looks perfect! Thank you!

This is very nearly what I want as well, but in that file, it pipes the readFile into markdownify, which is great, except that it doesn’t look like markdownify supports shortcodes; is there an equivalent command that does?