hugo-server
Serve Hugo website locally for preview
TLDR
Build and serve a site
Build and serve a site on a specified port number
Build and serve a site while minifying supported output formats (HTML, XML, etc.)
Build and serve a site in the production environment with full re-renders while minifying supported formats
Display help
SYNOPSIS
hugo server [--bind=<addr>] [--port=<port>] [--baseURL=<url>] [--watch] [flags]
PARAMETERS
-w, --watch
Watch filesystem for changes and rebuild (default true)
--port int
Port to listen on (default 1313)
--bind string
Address to bind to (default 127.0.0.1)
--baseURL string
Hostname (and scheme) for relative URLs
--appendPort
Append port number to baseURL
--disableLiveReload
Disable LiveReload.js
--disableFastRender
Disable fast render loop
-D, --buildDrafts
Include drafts in build
-F, --buildFuture
Include future content
-A, --all
Include all content (drafts, future, expired)
--destination string
Output directory (default public)
--themesDir string
Themes directory
--minify
Minify HTML, CSS, JS
--enableGitInfo
Add Git info to content
--logLevel string
Set log level (info, warn, debug)
DESCRIPTION
The hugo server command launches a local development server for Hugo static sites, providing instant previews with hot reloading. Hugo, a fast static site generator written in Go, rebuilds the site automatically upon content changes, CSS edits, or theme modifications.
Key features include:
• LiveReload: Browser auto-refreshes on file changes.
• Draft content support via -D flag.
• Customizable port (--port) and bind address (--bind).
• Serves from public/ directory by default.
Ideal for rapid prototyping, it watches the filesystem (unless disabled with -w=false) and regenerates pages efficiently. Supports future and expired content with flags like -F and -I. Use --baseURL for previewing production-like URLs. Disable features like LiveReload for headless testing.
Not for production; lacks HTTPS, compression, or caching optimizations found in servers like Nginx. Output mimics hugo build but streams to HTTP.
CAVEATS
Development-only; no production optimizations like HTTPS or caching. LiveReload requires JavaScript-enabled browser. High memory use with large sites or many watchers.
LIVERELOAD DETAILS
Injects livereload.js for auto-refresh. Configure via disableLiveReload or browser extensions.
CONFIGURATION OVERRIDE
Flags override config.toml settings like baseURL. Use --environment for dev/prod.
HISTORY
Hugo created in 2013 by Steve Francia (spf13). Server command introduced early for dev workflows, evolved with fast render (2015) and LiveReload improvements in v0.14+ (2015). Actively maintained by gohugo.io team.


