Use shortcodes in file included with `readFile`


I’m using a readfile shortcode and I’m including a Markdown file. However, the markdown file uses another shortcode. And that doesn’t get “expanded”. Any way in which I could force Hugo to recurse through the included file to expand the shortcode?

I’ve used two implementations of readfile shortcodes:

{{ $toRead := .Get "file" }}
{{ readFile $toRead | markdownify }}
{{$file := .Get "file"}}
{{- if eq (.Get "markdown") "true" -}}
{{- $file  | readFile | markdownify -}}
{{- else if  (.Get "highlight") -}}
{{-  highlight ($file  | readFile) (.Get "highlight") "" -}}
{{- else -}}
{{ $file  | readFile | safeHTML }}
{{- end -}}

Both fail to “recurse” through the shortcode keyword (img) in the included file.

I am unable to reproduce the problem as described. Try it:

git clone --single-branch -b hugo-forum-topic-40229 hugo-forum-topic-40229
cd hugo-forum-topic-40229
hugo server

If you require additional assistance, please post a link to the public repository for your project.


Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.