Essential Hugo commands for running the development server, building, and managing your HBStack-powered site including server commands, build options and debugging utilities.
Essential Hugo commands for development, building, and managing your HBStack-powered site including server commands, build options, and debugging utilities.
To start the Hugo development server, use the following command:
1hugo server
This command will start the server and watch for changes in your content files, automatically rebuilding the site as you make edits.
When a server is run while you want to build your site, you can use different configuration options. Learning about them always helps optimize your workflow. What commands are available can be seen from hugo help. Every command has its own set of flags and options that can be used to customize its behavior.
By default hugo server will use development configuration. Hugo allows you to have multiple configuration sets in config directory.
Conventionally there are three different environments. Default, development and production but often one more named staging is also seen to be present.
1config
2.
3├── _default
4│ ├── hugo.yaml
5│ ├── languages.yaml
6│ ├── menus.en.yaml
7│ ├── module.yaml
8│ └── params.yaml
9├── development
10│ ├── hugo.yaml
11│ ├── params.yaml
12│ └── server.yaml
13└── production
14 ├── hugo.yaml
15 └── params.yaml
Note
It is important to understand how configurations are loaded to work with hugo and go moduling system. Running
hugo,hugo serverandhugo server -e defaultall have different meaning.
hugo, it will run the server in productionhugo server will always use development as if ran with -e development flag.flags are used when running server.1hugo server -e default
2hugo server -e development
3hugo server -e production
If configuration setup is not present and only hugo.yaml is present then the same rule given above applies. The hugo command will start production server while hugo server command will server the site on some port. Hugo assumes that running hugo server you are in development mode
Caution
If a
_default, development and productionor any other environments are present, you must specify the environment when running the server.
1npm run dev,
2
3# Where dev is a script as follows
4
5script {
6"dev": "hugo server -- port 3040" # will run the server in development environment but ambiguous
7"dev": "hugo server -e development -p 3040" # correct,specific and un ambiguous
8}