2014-05-27 22:32:57 +00:00
|
|
|
|
---
|
2014-05-29 22:42:05 +00:00
|
|
|
|
date: 2014-05-26
|
2014-05-27 22:32:57 +00:00
|
|
|
|
menu:
|
|
|
|
|
main:
|
2014-05-29 22:42:05 +00:00
|
|
|
|
parent: extras
|
|
|
|
|
next: /extras/menus
|
2014-11-25 08:07:18 +00:00
|
|
|
|
prev: /extras/crossreferences
|
2015-01-09 18:51:15 +00:00
|
|
|
|
title: LiveReload
|
2014-11-25 08:07:18 +00:00
|
|
|
|
weight: 50
|
2014-05-27 22:32:57 +00:00
|
|
|
|
---
|
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
Hugo may not be the first static site generator to utilize LiveReload
|
2014-05-27 22:32:57 +00:00
|
|
|
|
technology, but it’s the first to do it right.
|
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
The combination of Hugo’s insane build speed and LiveReload make
|
2014-05-27 22:32:57 +00:00
|
|
|
|
crafting your content pure joy. Virtually instantly after you hit save
|
|
|
|
|
your rebuilt content will appear in your browser.
|
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
## Using LiveReload
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
Hugo comes with LiveReload built in. There are no additional packages to
|
|
|
|
|
install. A common way to use Hugo while developing a site is to have
|
|
|
|
|
Hugo run a server and watch for changes:
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
$ hugo server --watch
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|
|
|
|
|
This will run a full functioning web server while simultaneously
|
|
|
|
|
watching your file system for additions, deletions or changes within
|
|
|
|
|
your:
|
|
|
|
|
|
|
|
|
|
* static files
|
|
|
|
|
* content
|
|
|
|
|
* layouts
|
|
|
|
|
* current theme
|
|
|
|
|
|
|
|
|
|
Whenever anything changes Hugo will rebuild the site, continue to serve
|
|
|
|
|
the content and as soon as the build is finished it will tell the
|
|
|
|
|
browser and silently reload the page. Because most hugo builds are so
|
|
|
|
|
fast they are barely noticeable, you merely need to glance at your open
|
|
|
|
|
browser and you will see the change already there.
|
|
|
|
|
|
|
|
|
|
This means that keeping the site open on a second monitor (or another
|
2015-01-09 18:51:15 +00:00
|
|
|
|
half of your current monitor) allows you to see exactly what your
|
2014-05-27 22:32:57 +00:00
|
|
|
|
content looks like without even leaving your text editor.
|
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
## Disabling LiveReload
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
LiveReload works by injecting JavaScript into the pages it
|
2014-05-27 22:32:57 +00:00
|
|
|
|
creates that creates a web socket client to the hugo web socket server.
|
|
|
|
|
|
|
|
|
|
Awesome for development, but not something you would want to do in
|
|
|
|
|
production. Since many people use `hugo server --watch` in production to
|
|
|
|
|
instantly display any updated content, we’ve made it easy to disable the
|
2015-01-09 18:51:15 +00:00
|
|
|
|
LiveReload functionality.
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|
2015-01-09 18:51:15 +00:00
|
|
|
|
$ hugo server --watch --disableLiveReload
|
2014-05-27 22:32:57 +00:00
|
|
|
|
|