Skip to content

Commands

You can use the scripts in package.json to create new content and develop, format, build, and preview your project from a terminal window.

package.json scripts

The following scripts for the most common commands (create, dev, format, build, and preview) are added for you automatically when you create a project using the create hyas wizard.

When you follow the instructions to install Hyas manually, you are instructed to add these scripts yourself. You can also add more scripts to this list manually for any commands you use frequently.

package.json
{
"scripts": {
"create": "hugo new",
"dev": "hugo server --disableFastRender --noHTTPCache",
"format": "prettier **/** -w -c",
"build": "hugo --minify --gc",
"preview": "vite preview --outDir public"
}
}

You will often use these commands, or the scripts that run them, without any flags. Add flags to the command when you want to customize the command’s behavior. For example, you may wish to start the development server on a different port, or build your site with verbose logs for debugging.

Terminal window
# Run the dev server on port 3000 using the `dev` script in `package.json`
npm run dev -- --port 3000
# Build your site with verbose logs using the `build` script in `package.json`
npm run build -- --verbose

create

Run the following command in your terminal to create new content:

Terminal window
# npm run create [path] [flags]
npm run create

For example, create an about page in the content directory of your project:

Terminal window
npm run create about.md

dev

Run the following command in your terminal to start the Hugo development server:

Terminal window
# npm run dev [flags]
npm run dev

format

Run the following command in your terminal to run the Prettier code formatter:

Terminal window
# npm run format [flags]
npm run format

build

Run the following command in your terminal to create a production build:

Terminal window
# npm run build [flags]
npm run build

preview

Run the following command in your terminal to locally preview the production build:

Terminal window
# npm run preview [flags]
npm run preview