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 Thulite 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.
{ "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.
# 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# run the dev server on port 3000 using the `dev` script in `package.json`pnpm dev --port 3000
# build your site with verbose logs using the `build` script in `package.json`pnpm build --verbose# run the dev server on port 3000 using the `dev` script in `package.json`yarn dev --port 3000
# build your site with verbose logs using the `build` script in `package.json`yarn build --verbosecreate
Run the following command in your terminal to create new content:
# npm run create [path] [flags]npm run create# pnpm run create [path] [flags]pnpm run create# yarn run create [path] [flags]yarn run createFor example, create an about page in the content directory of your project:
npm run create about.mdpnpm run create about.mdyarn run create about.mddev
Run the following command in your terminal to start the Hugo development server:
# npm run dev [flags]npm run dev# pnpm dev [flags]pnpm dev# yarn dev [flags]yarn devformat
Run the following command in your terminal to run the Prettier code formatter:
# npm run format [flags]npm run format# pnpm format [flags]pnpm format# yarn format [flags]yarn formatbuild
Run the following command in your terminal to create a production build:
# npm run build [flags]npm run build# pnpm build [flags]pnpm build# yarn build [flags]yarn buildpreview
Run the following command in your terminal to locally preview the production build:
# npm run preview [flags]npm run preview# pnpm preview [flags]pnpm preview# yarn preview [flags]yarn preview