Open navClose nav

Instant Previews

This feature is currently in beta.

With instant previews, you can take advantage of your static site generator’s built-in “watch” or incrementally-updating mode to dramatically reduce the time it takes to refresh a Forestry preview, providing a shorter feedback cycle for editors working on your site.

Before You Start

In order to use instant previews, your site must be using Key-based Authentication to access your Git repo. Sites created before August 28, 2018 may need to perform a manual upgrade in order to work with instant previews.

Upgrade Guide: Key-Based Authentication

Adding an Instant Preview

Instant previews are configured just like other build commands. To use instant previews, navigate to Settings > Previews. Activate the Instant Previews toggle to enable this feature.

Once the Instant Previews toggle is activated, your dev server will start spinning up in our preview environment and you will be able to edit the Instant Preview Command.

preview settings

You can edit the command used to run your dev server by editing the Instant Preview Command field.

Preview Settings In .forestry/settings.yml

Alternatively, you can add your instant preview command directly to your configuration file in .forestry/settings.yml by adding a value named instant_preview_command under the build section. You can activate instant previews by adding instant_preview: true to the top-level configuration.

Here’s an example of a live preview configuration in a .forestry/settings.yml file:

instant_preview: true
build:
    instant_preview_command: hugo server -D --renderToDisk --port 8080 --bind 0.0.0.0

Your instant preview command will use the same output directory and environment variables as the standard preview command.

Command Limitations

Your instant previewing command needs to be a “watch” style command that will start a process to watch for changes to your files, and rebuild your site automatically. This will most likely be the command that a developer would run in their local environment when working on the site, such as hugo server or jekyll serve.

A Caveat for Hugo users

You must include the --renderToDisk flag when starting the Hugo server in order for your site to work with our preview system.

Network Details

Your preview needs to run on port 8080 and bind to all network interfaces (0.0.0.0).

hugo server --renderToDisk --port 8080 --bind 0.0.0.0
bundle exec jekyll serve --port 8080 --host 0.0.0.0
vuepress dev --port 8080 --host 0.0.0.0
gatsby develop -p 8080 -H 0.0.0.0
HugoJekyllVuePressGatsby [beta]

Live Reloading

Forestry’s live previewing relies on the built-in live browser reloading provided by your preview process. Instant previews have been tested and confirmed working with Browsersync and LiveReload.

Default Instant Preview Commands

See default build commands for the default instant preview commands for each supported SSG.

Using The Preview

Note that your live preview will initially start on the homepage of your site, regardless of which content you initialize the preview from.


Last updated on January 5, 2019