Search code examples
rhugoblogdownhugo-shortcode

Fixing broken relative links in RSS feed for blogdown posts using Hugo


Overall, the topic of my question is an old one: how to fix image paths to be absolute in RSS feed. As @Yihui notes, this is mostly a Hugo problem, not a blogdown problem, and is a problem everyone using R-bloggers will have. As this SO thread points out, there is no simple way to make RSS image paths be absolute in RSS, but to write them by hand in each post. @Yihui provided a much better solution (see here and here) by using a Hugo shortcode and replacing ![](foo.png) with ![]({{< blogdown/postref >}foo.png}) within Rmarkdown documents.

Everything seems fine, but when I do the replacement I get:

Error: Error building site: "E:\path\blog\content\post\name_post\index.en.markdown:1:1": unrecognized character in shortcode action: U+003E '>'. Note: Parameters with non-alphanumeric args must be quoted

It seems that Hugo doesn't recognize the shortcode (or that it ends with last }). I checked blogdown/postref.html and it is up to date, I installed newest version of Hugo, updated blogdown and dependencies, ran blogdown::check_site() (and blogdown::serve_site()). Nothing helped.

Any idea where the error issue lies and how to fix? Thank you.


Solution

  • ![]({{< blogdown/postref >}foo.png})
    

    should be

    ![]({{< blogdown/postref >}}foo.png)