/willmeyers' blog

Pass Data to Content Markdown Files in Hugo

Here's a simple shortcode template that passes in any data file within your Hugo blog's data directory into any page in your content directory.


{{ $data := index $.Site.Data (.Get "datafile") }}
    window[{{ .Get "var" }}] = {{ $data }};


title: "Data"

{{<data var="myData" datafile="data_file_name">}}

You can now access myData in any other scripts attached to your markdown page.