rrstudior-markdownblogdownhugo-shortcode

Cannot use Markdown shortcodes in Blogdown's Rmd files


I am using Blogdown. In my post.Rmd file I need to use a shortcode:

This is me calling a **shortcode**:

`r blogdown::shortcode("mysc", .content = "Find **more** about this shortcode in [here](https://www.wikipedia.com).")`

As you can see, .content is Markdown, not plain text. Shortcode mysc.html is:

<p class="sc">
  {{ if .Inner }}
    {{ .Inner }}
  {{ end }}
</p>

As you can see, I am using blogdown::shortcode because it is not possible to use shortcode syntax in Rmd files.

Problem

However the Markdown in .content is not converted into HTML, I get this as output:

<p>
Find **more** about this shortcode in [here](https://www.wikipedia.com).
</p>

What am I doing wrong?


Troubleshooting

Note that specifying .type does not help:

`r blogdown::shortcode("mysc", .content = "...", .type = "markdown")`

Also it should not be necessary as it defaults to "markdown". And it still renders the same exact output if I specify .type = "html". What the hell is going on here?


Solution

  • As I mentioned in the Github issue you referenced, Hugo changed the behavior of {{% %}}. Personally I feel it is a breakage. Before it is fixed, I think your only options are