Data files

Is there a way to have one content or data file for the entire site?

All of my pages use common variables and would like to keep my code DRY.

Yes, if your entire site is one page.

Hugo doesn’t create pages from nothing. Single pages require a content file for each one. List pages are created for various things, but it is based on file path and metadata, not a single page and data files.

Yes, there is one way… if you use Org mode, and use the ox-hugo1 exporter (an Emacs package that exports Org mode files to Markdown files with front-matter compatible with Hugo/Blackfriday – This is an external tool i.e. not maintained by Hugo) :slight_smile:


1 The content for that whole site is from this one file.

To clarify, this is an external tool. Hugo does not generate the pages. :slight_smile:

Yes, let me add that.

It is Hugo that generates the pages… the flow is like this:

          Org file –ox-hugo→ Markdown files –hugo→ HTML

The user never needs to update the Markdown files manually.

Another slightly related native-Hugo-supported approach for “all content in one file” is have content as variables in the site’s config.toml and then rendering those in the site’s index.html. The single-page Creative theme is one such example.

You should be able to use the same approach using data files too, but then in these config.toml/data file approach, you need to have the layout files configured for each page you want to render.