Content adapters: generating a single page

Reading the new feature at Content adapters | Hugo, I’d like to be able to generate a single page from a JSON or TOML file.

The use-case would be having a page of links that’s updated by adding an entry to the data file, rather than editing markdown.

It’s not clear to me if you can use a content adapter or Go templating for single pages, rather than an entire category of content.

Am I looking at the right concept here?

You can use a content adapter to create a single page, but in this case it sounds like that would be the wrong approach.

Instead, create a (mostly) empty markdown file:

hugo new content content/

In its front matter:

layout = 'page-of-links'

Then create a template at layouts/_default/page-of-links.html:

{{ define "main" }}
  <h1>{{ .Title }}</h1>
  {{ .Content }}

  {{ range site.Data.something }}
    {{ .foo }}
  {{ end }}
{{ end }}

Thanks @jmooring! This is exactly what I was after.

1 Like

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