Rendering in a file_server block


I have simple caddy server that are serving some repositories content

:80 {
        root * /opt/repos
        file_server {
                hide *.log *.logs .*

I was wondering if there a way to render like in gitlab or github

for example,


  • file1
  • file 2

when browsing and is found is it possible to render the content in page?

Yes it is! I’m mobile ATM but I’ll reply with an answer soon.

Thank you for your fast reply. Looking forward for it,

The basic idea is you can render markdown as HTML using templates:


Then you’ll need a templated file that runs the {{markdown}} action. You can see how we render our Markdown docs as HTML in our own GitHub repo:

That might be a little more advanced than what you need. But the basic idea is there. You’ll also need to rewrite requests to your .md files to go to your template file so they can render the requested Markdown file instead.


You can also treat your README filenames as “index” files:

file_server {
    index index.html

for example. That will prevent directory listings when a file is present, if you want to just show the readme instead. But that’s optional.

I’d be open to discussing ways to make this easier, but we did something like this in v1 with a markdown directive. The problem is that Markdown files, by themselves, aren’t generally useful for display as part of a website. There’s no styles or JS, there’s no header, footer, or nav. It’s just a plain-looking, bare-bones HTML document. Maybe that’s fine, but we found most people needed the ability to put markdown within something like a template.

And templates allow you to preface your Markdown with front matter, which can be used in the template as variables/values!

Hi, Thanks for the ideas. what i want is really something similar to Gitlab/github where the readme is included with the index directory.

i am almost sure it’s possible with the template you gave i’ll have to give it a try, sorry for the late reply as i am on vacation right now =)


so far this seems to work as requested.

Thank you

1 Like

Ohh I see. Yes that should do then! :slight_smile: glad you figured it out and thanks for sharing!

1 Like

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