I want to automatically embed code from .go files highlighted in my post (markdown or html, doesn’t matter). What is the easiest way to do so with Hugo?
Here are some more details of what I’m planning:
I want to have a folder of source code files, like example1.go.
I want to store metadata to these files in a JSON file, like { "name": "example1", "author": "me", "output": "hello world" }.
It doesn’t matter if its one big JSON file or multiple.
I want to create a post that contains the metadata and the code. One post will always have exactly one code example and one example is only embedded into one post.
I think I know how to read the metadata and include it into the post, but how could I include the code?
git clone --single-branch -b hugo-forum-topic-36662 https://github.com/jmooring/hugo-testing hugo-forum-topic-36662
cd hugo-forum-topic-36662
hugo server
I had not seen .TranslationKey being used this way. Is there a specific reason to use that? I would have just used {{ $key := .File.BaseFileName }}. So I am curious to know if using .TranslationKey is just a preference or it does something better.