Remote .md File Render

I store all my doc files on github in markdown format. How can I read these files and display them on my page in Hugo?

For example, someone goes to docs/getting-started and it will know to pull the getting-started.md file from the URL that relates to said file on github.

Hi TheRov, welcome to the forum! :wave:

You can read files with the readFile function.

You probably want to use the .RenderString function for that, since that one turns Markdown into HTML.

Another option is the markdownify function, but that one is a little bit less advanced than .RenderString.

1 Like

Just what I needed! thank you so much!!

When I try to use readFile it tells me the file doesn’t exist. The syntax is {{readFile “https://raw.github.com/repo/project/file.md”}}

I believe for remote files you’ll need to use the API to get the content:

I don’t know the details here, but I suggest you look into Hugo Modules and content mounts (which can be remote).