Render markdown from .md files within a separate GitHub repo


I’m wondering if it is possible to render a markdown file within Hugo based off of a link to a markdown file. The reason being is that it would be nice to have some of the readmes from our repo on our Hugo site, without having to manage the same content in two files.

e.g. Say in Hugo I have a file, and in that file I only want to render what is at

Would this be possible?


You could mount the repo in question and use it’s as you content. There’s also Probably other ways, as well. :slight_smile:

Interesting, yeah I was looking into the readFile function but I wasn’t sure if it would support a link, since it says it’s for local files

I presumed you meant local file. To load remote data, maybe you can use some API to get a JSON representation of the file in question. But there is not currently a way to load markdown from a remote endpoint in Hugo.

Hugo modules is still an option (making remote files local, cached).

I ended up getting it to work with this, so now I just need to figure out how to store my secret and pull that in :slight_smile:


 <script src=""></script>
<div id="markdown" style="height: 100%;"></div>
<script type="module">
  import { Octokit } from "";

  const octokit = new Octokit({
    auth: "MY_SECRET",
    userAgent: "goalert",
    baseUrl: "",

      owner: "target",
      repo: "goalert",
      path: "{{ .Get 0 }}",
    .then((result) => {
      // content will be base64 encoded
      var content = atob(;
      // replace rel links from github markdown with abs links
      var toUrl = "";
      content = content.replace(/\]\(\./g, "](" + toUrl);
      // render within div
      document.getElementById("markdown").innerHTML = marked(content);

and then in my I have {{< renderMarkdownFromGoAlert "" >}} where that parameter is the path to the file in our repo. Working great so far!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.