Linux command
hugo-server 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start development server
hugo server
Include draft content
hugo server -D
Start on a custom port
hugo server -p [8080]
Bind to all interfaces
hugo server --bind 0.0.0.0
Disable live reload
hugo server --disableLiveReload
Navigate to changes
hugo server --navigateToChanged
Build and serve with a specific base URL
hugo server --baseURL [http://example.com]
说明
hugo server starts a local development server with live reload. It watches for file changes and automatically rebuilds the site, then signals connected browsers to refresh via injected JavaScript. The server renders content to memory by default for speed. It defaults to localhost:1313 and enables watching/live reload automatically.
参数
- -D, --buildDrafts
- Include draft content.
- -E, --buildExpired
- Include expired content.
- -F, --buildFuture
- Include content with future publish dates.
- -p, --port _PORT_
- Server port (default: 1313).
- --bind _ADDR_
- Listen address (default: 127.0.0.1).
- -b, --baseURL _URL_
- Hostname and path to the root.
- --disableLiveReload
- Disable automatic live reloading of browser.
- --navigateToChanged
- Navigate to changed content file on live reload.
- --poll _DURATION_
- Use polling with this period for file change detection (e.g., 700ms).
- -w, --watch
- Watch for changes and rebuild (default: true).
- --noHTTPCache
- Prevent HTTP caching.
- --renderStaticToDisk
- Serve static files from disk and dynamic files from memory.
- --help
- Display help information.
FAQ
What is the hugo-server command used for?
hugo server starts a local development server with live reload. It watches for file changes and automatically rebuilds the site, then signals connected browsers to refresh via injected JavaScript. The server renders content to memory by default for speed. It defaults to localhost:1313 and enables watching/live reload automatically.
How do I run a basic hugo-server example?
Run `hugo server` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -D, --buildDrafts do in hugo-server?
Include draft content.