CloudCannon Hugo
Creates CloudCannon build information for sites made with Hugo.
This tool runs after your Hugo build, reading your configuration to find pages, collections, and
data files to create a JSON file used to automatically integrate the site with CloudCannon. This
JSON file is written to _cloudcannon/info.json
in your destination folder.
Installation
You don't have to install anything when building on CloudCannon. This tool is automatically
installed before your site is built. This gives you the latest support, new features, and fixes
as they are released.
Although not necessary, you can install the tool locally to debug an integration issue.
Manual installation steps
$ npm install --global cloudcannon-hugo
This gives you access to the cloudcannon-hugo
binary.
Configuration
Configuration files should be in the root directory (or the same directory you run
cloudcannon-hugo
). The first supported file found in this order is used:
cloudcannon.config.json
cloudcannon.config.yaml
cloudcannon.config.yml
cloudcannon.config.js
cloudcannon.config.cjs
Alternatively, use a specific file with the CLOUDCANNON_CONFIG_PATH
environment variable:
$ CLOUDCANNON_CONFIG_PATH=src/cloudcannon.config.js cloudcannon-hugo
Your global CloudCannon configuration is set in this file as well, as it's used as a base to
generate _cloudcannon/info.json
(used to integrate your site with CloudCannon).
Example content for cloudcannon.config.yml
:
_inputs:
title:
type: text
comment: The title of your page.
_select_data:
colors:
- Red
- Green
- Blue
source: src
base_url: /documentation
collections_config:
people:
path: content/people
output: true
name: Personnel
_enabled_editors:
- data
posts:
path: _posts
output: true
pages:
name: Main pages
data_config:
authors: true
offices: true
paths:
uploads: assets/uploads
data: _data
layouts: _layouts
See the CloudCannon documentation for more information
on the available features you can configure.
Configuration is set in cloudcannon.config.*
, but the tool also automatically
reads and processes the following from Hugo if unset:
collections_config
from your folder structure inside contentDir
in Hugo configpaths.layouts
from layoutsDir
in Hugo configpaths.data
from dataDir
in Hugo configpaths.static
from staticDir
in Hugo configbase_url
from the --baseURL
CLI option or baseURL
in Hugo configsource
from source
in Hugo config
Development
Install dependencies:
$ npm i
Lint code:
$ npm run lint
Testing
Run tests:
$ npm test
$ npm run test:integration
$ npm run test:all
$ npm run report-coverage
Link this package locally to test it on a site folder, then run it within your site folder:
$ npm link
$ cd ../my-hugo-site
$ cloudcannon-hugo
Releasing new versions
Prerelease:
$ npm run release:next
Release:
$ npm run release:latest
License
ISC