Running Hugo Server

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.


Running Hugo Server

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.

Server Configuration Options

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.

  • These configuration are defined as follows:
 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
  1. To remember it start with hugo, it will run the server in production
  2. Similarly hugo server will always use development as if ran with -e development flag.
  3. To run the server with specific environment flags are used when running server.
  4. Following commands assumes that your configuration setup is present in your site directory.
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

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}

How Hugo works

FAQs