Rendering templates

I am building a website based on markdown files and templates. In one folder, I would like to make a nice index page with a thumbnail for each page of the folder. For each page (a markdown file), the picture’s URL is declared in the page’s front matter. But right now, I can’t find a way to access those metadata in order to display more than a link.

The way hugo is doing it is rather simple:

  1. I define a template that displays my page as a clickable thumbnail
  2. In my index template, I render each file of the index through that template, through the {{ .Render "template"}} function.

Is there a way to do something similar with caddy? Would it make sense to add a .Render function to caddy’s template?

Doesn’t Hugo output static files when you run it? Render once, serve static files many times?

If your site is just markdown and templates to be rendered on each request, then on a request for the index, Caddy would need to open and read every single MD file in order to inspect the front matter and pull the image URL into an image tag, right?

Yes, hugo is a static site generator - all the pages are produced once and then uploaded.

Yes, in what I described, caddy would have to open each page in the folder in order to render the index, would that be problematic?

Anyway, I’m unsure what I want to do is possible with caddy in its current shape. But if it was possible to pass the name of the template to the .Markdown template action (overriding the one defined in the markdown front matter), I could do something like that:

		<title>{{html .Name}}</title>
		{{range .Items}}
                {{.Markdown .URL "thumbnail" }}

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