Serve Hugo website during local development using code-server.

I am assuming that you are using default configuration for development.

$ tree config/
├── _default
│   └── config.yml
└── production
    └── config.yml

3 directories, 3 files

Create additional environment.

$ mkdir config/code-server-development

Enforce relative URLs.

$ echo "relativeURLs: true" | tee config/code-server-development/config.yml

Use code-server terminal to start built-in server. Notice that port is hidden, live browser reload is disabled, and environment defined earlier is used.

$ hugo server --clock $(date +"%Y-%m-%d" --date "next week") --appendPort=false --baseURL="/" --disableLiveReload --environment="code-server-development" 
Start building sites … 
hugo v0.108.0-a0d64a46e36dd2f503bfd5ba1a5807b900df231d+extended linux/arm64 BuildDate=2022-12-06T13:37:56Z VendorInfo=gohugoio

                   |  EN   
  Pages            | 1571  
  Paginator pages  |    0  
  Non-page files   |    0  
  Static files     | 2078  
  Processed images |    0  
  Aliases          |    0  
  Sitemaps         |    1  
  Cleaned          |    0  

Built in 7213 ms
Watching for changes in /home/milosz/Projekty/{assets,content,layouts,static,themes}
Watching for config changes in /home/milosz/Projekty/, /home/milosz/Projekty/
Environment: "code-server-development"
Serving pages from memory
Web Server is available at / (bind address
Press Ctrl+C to stop

Change detected, rebuilding site.
2023-01-30 01:00:28.908 +0100
Source changed WRITE         "/home/milosz/Projekty/"
Total in 4892 ms


Use ports tab to inspect forwarded port.

code-server ports

Open to access development site.