Header

Using DeployHQ to build your static site

Tips & Tricks

Static websites are very popular in modern web development due to their improved performance compared to traditional server-client rendered sites.

By precompiling all assets in a ready state to be served directly to the client's web browser, this makes a site smaller, and can improve download times as the server doesn't need to run additional processes such as database queries before rendering a page.

As static sites can be written completely in HTML and serve the same page for every visitor, this makes them very popular for news sites and blog posts.

There are a number of widely used frameworks for static site generation including but not limited to:

  • Hexo
  • Hugo
  • Gatsby
  • Jekyll
  • Next.js

These all work similarly, by compiling a full site based on a predefined set of parameters, often found in a simple manifest file as JSON along with a series of templates.

Building a static site in DeployHQ

Traditionally, developers might pre-compile a site either locally before committing it to their version control system, or on the destination server. This isn't always suitable, as from the local compilation perspective this can bloat a repository with unnecessary assets and cause merge conflicts if multiple developers are working on the same site. On the server side, especially in certain environments, it simply might be possible to run compilation commands.

DeployHQ's Build Pipeline has a number of built-in languages and tools that allow you to build a site before it's deployed to the destination server. Using Gatsby as an example, you'll normally just need to run the following commands:

npm install
npm run build

Then the resultant files will be deployed to the server. Some speed advantages can be gained during deployments with Build Caching to keep a local copy of the dependencies fetched via npm install, and on a normal deployment, only the files changed since the last build will be uploaded, meaning unnecessary file transfers don't happen.

We have a number of guides for static site generators on our website that you can take a look at, and if you have any questions about how DeployHQ can help with building and deploying your Static Site, please don't hesitate to get in touch.

A little bit about the author

I'm Adam W, or as everyone prefers to call me - Batman. I get a lot of satisfaction out of helping our customers and am committed to making their customer experience as positive as possible. When not offering support to our customers, you'll find me gaming, listening to music or running.

Proudly powered by Katapult. Running on 100% renewable energy.