/hugo-data-to-pages

Generate pages from data on Hugo

Primary LanguageJavaScriptMIT LicenseMIT

Hugo Data to Pages

Allows for generating pages (or any archetypes) from data (json/yaml) on Hugo. Related to issues #140 and 5074.

Getting Started

This script is a simple wrapper that:

  • Generates the pages under your content folder
  • Runs Hugo
  • And finally, removes the generated pages

The entire script is in hugo.js, the example/ is just an example hugo site.

Prerequisites

  • hugo
  • node & npm

Installing & Running

  • Run npm install to install dependencies
  • Run node hugo.js to build
  • (optional) Run chmod +x hugo.js to allow for direct execution, i.e. ./hugo.js
  • Go to localhost:1313 to see links to the generated pages

Commands

There are 3 available commands:

  • ./hugo.js (basically hugo build to public directory)
  • ./hugo.js generate (only generate folders/files from data, same as above but without executing hugo build)
  • ./hugo.js server (basically hugo server, with cleanup on exit)
  • ./hugo.js clean (trigger cleanup in case the script didn't remove the generated folders)

Flags:

  • -c FILE.json or --configFile FILE.json flag to override default config (check hugoConfig-example.json)
  • -f or --force flag to skip folder removal prompts (be careful with this one!)

Author

kidsil

License

This project is licensed under the MIT License - see the LICENSE.md file for details