Is there a way to render a remote/external markdown file?

I’m interested to understand if there’s a way to reference markdown content located via an URL (e.g. and have that rendered inline with a page in Grav?

I have a wide smattering of github repos with markdown that I don’t want to change.
I’d like to be able to aggregate that content within a site powered by Grav and allow creating new content that has nothing to do with any of the aforementioned github repos.

I’m open to various solutions such as plugins, Twig, etc.

Any suggestions?

Trevor Ackerman

It’s possible, but not out-of-the-box.

  1. Create a custom twig function to pull a remote URL into a string, then use the |markdown filter on that string. The problem here is that there’s no caching, and every page requests has to request this file and parse it.

  2. Create a custom plugin that retrieves the file, markdown-parses it and stores it as a variable. Potentially, you could add caching to this call so it’s not run every time.

  3. Create a cron job or something that simply pulls the remote file and stores it in the Grav user/pages/ structure, so Grav treats it like a regular markdown page that you can access and display with page->find('/username/myrepo/')->content()

There are other ways, but that’s just 3 off the top of my head.