How to include file with html in a post written in markdown

I am new here. Tried jekyll for a few days and then started considering Hugo. So far I like it.

For now, I am trying to replicate something I did before (in Jekyll) but it’s seems I don’t understand how to do it in Hugo.

In Jekyll, I was able to accomplish that using:

{% include {{ filename | prepend:site.baseurl }} %} where filename points to the html file.

Basically, I want to include (import, insert) a html file from a directory under the partials directory. This table is better included as a file because it is a large table and I have another program that runs and writes out the html file when I need to update the table. This html file is not a template file but rather a fully specified html file (table) that does not need any processing but rather just copying and pasting in my post.md file.

So far, I did:
{{ partial “post/somepath/table.html” .}} inside the markdown but this does not seem to include the table in the post and that particular command bleeds through to my post. I tried added the % symbol but that didn’t work too.

Please post suggestions on how to accomplish this or kindly point me to an answer somewhere elsewhere.

Thanks,

Jay

The next release of Hugo (v0.16) will include a readFile template function.

Also see shortcodes.

Thanks. Any idea when that will be out.

In the mean time, please can you let me know to accomplishing this: I am trying to get something to just copy the html file and paste it into the *.md (for post) file.

This is advanced usage, so be prepared. You can’t use template functions directly within markdown. You have to use shortcodes as a gateway. So, say you have a partial template in layouts/partials/somepath/table.html. You could do something like this:

{{< importPartial "somepath/table.html" >}}

Create a shortcode as layouts/shortcodes/importPartial.html that does something like this:

{{ partial (.Get 0) .Page }}

I haven’t tested that, but it may get you close to a solution.

Thanks @moorereason.

Your suggestion worked and my html table came through in the post. I will have to read up more on shortcodes to understand it better but for now, I will use your solution for my importing needs.

If you don’t mind me asking, are you a superuser or one of the developers. I just started using Hugo since yesterday and getting past this was important for me.

Thanks once again.