Deploying static sites
To push static content to the web, use the Staticfile buildpack. Examples of static content are front-end JavaScript apps and static HTML content.
To set up a “hello world” demo or a more complex static site, see the Cloud Foundry Staticfile buildpack documentation. It includes “hello world” instructions and a full list of configuration options, including how to set up basic authentication and configure nginx (the underlying web server).
Builds
If you are using a static site generator (e.g. Jekyll or Hugo) and/or it requires dependencies to be installed at deploy-time, you should set up continuous deployment. This way, the build happens in your Continuous Integration (CI) system rather than during the deploy itself within Cloud Foundry. This helps to make your deployments more reliable, have a smaller footprint, and reduce downtime.
Jekyll
Deploying a Jekyll site requires a few things:
-
Add or update your
Gemfile
to include thejekyll
gem.source 'https://rubygems.org' gem 'jekyll'
-
Add a
Staticfile
pointing to the root of the built site, as specified in the Cloud Foundry Staticfile buildpack documentation.root: _site
See 18F/notalone for an example.
Redirect all traffic
If a site moves to a different domain name, you can use cf-redirect to redirect all traffic from the old domain to the new domain.
You can read more about nginx customization at the Staticfile Buildpack documentation.