Harold is a static site generator that can help quickly set up websites, blogs, documentation sites, and other simple static websites.
Check out the demo of predefined templates, which you can use:
Below you can watch a quick walk-through video:
npx
npx create-harold-app@latest my-app
(npx is a package runner tool that comes with npm 5.2+ and higher, see instructions for older npm versions)
npm
npm init harold-app@latest my-app
(npm init is available in npm 6+)
yarn
yarn create harold-app@latest my-app
(yarn create is available in Yarn 0.25+)
It will create a directory called my-app inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies.
As an option, you can choose with which template it should init the project. Possible choices:
If you want to init the project with docs
template, pass additional option -t docs
. For example: npm init harold-app@latest my-app -t docs
or with npm 7+ npm init harold-app@latest my-app -- -t docs
. The same for bare
template.
In the future, there will be a possibility to pass custom templates.
Write create-harold-app@latest --help
in a terminal to get the list of options.
From the newly created app's directory (in our case, my-app), run npm start
. It will serve the app under localhost:3000
. To change the port, just add PORT
env, like: PORT=3002 npm start
.
Harold will search up the directory tree for configuration in the following places:
harold
property in package.json.haroldrc
file in JSON or YAML format.haroldrc.json
, .haroldrc.yaml
, .haroldrc.yml
, .haroldrc.js
, or .haroldrc.cjs
fileharold.config.js
or harold.config.cjs
CommonJS module exporting an objectFor now, there isn't much to configure, but you can configure the directory for md files (by default posts
) and the directory for md files layouts (by default blog-layouts
). Quite helpful because these names are also used in urls. For example, by default, /posts/name-of-the-post
(name of the .md file), but you might want to build the docs website and have /docs/name-of-the-doc
(name of the .md file).
You can also configure the name for output directory using outputDirName
and if you want to host your site in subdirectory you would also need to add hostDirName
.
Example of .haroldrc
(placed in the root of your harold app):
{
mdFilesDirName: 'docs',
mdFilesLayoutsDirName: 'docs-layouts',
outputDirName: 'dist',
hostDirName: 'subfolder-name'
}
Remember to change these directories' names after you init your app.
If you are using the search system, change postsPath
in harold-search.js
.
harold-scripts is the fundamental toolset that will run the dev server and build a static site. It comes as a dependency from a separate package.
You don't have to think about it much. Create Harold App will install it when initializing the project. The package.json file of the newly created project will already have a configuration for a start
and build
scripts using harold-scripts.
Updating your project:
harold-scripts
harold-scripts
package