TheRov
January 16, 2020, 2:50pm
#1
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.
Jura
January 16, 2020, 4:20pm
#2
Hi TheRov, welcome to the forum!
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
TheRov
January 16, 2020, 4:26pm
#3
Just what I needed! thank you so much!!
TheRov
January 16, 2020, 6:20pm
#4
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 ”}}
b_rad
January 16, 2020, 7:15pm
#5
I believe for remote files you’ll need to use the API to get the content:
bep
January 16, 2020, 7:16pm
#6
I don’t know the details here, but I suggest you look into Hugo Modules and content mounts (which can be remote).