Homepage /Articles/Publish series/Build a website using Publish
Publish logo indicating Publish series number 1Nov 1, 2021

Build a website using Publish

This is part of Publish Posts Series.

What's a static website?

A static website delivers its content as it's stored. That means there's no backend/server that process the request in any special way to build the HTML. This can improve performance in displaying the website.

This kind of website is suited for content that rarely changes or for blogging, documentation or similar that doesn't need dynamic features.

What's Publish?

Publish is a static web generator built in Swift by Jonh Sundell .

It uses Swift programming features like DSL to generate the static website. It comes with a default theme that's focused on blogging. The content is created in markdown files that Publish converts using the theme into static HTML pages.

How to set up Publish?

Installation

First of all, it's necessary to install Publish, clone the repo and run $ make as shown below.

$ git clone https://github.com/JohnSundell/Publish.git
$ cd Publish
$ make

Once this completes successfully, it's time to create the website. To do that let's create a folder with the name of the website and open it. Once is open run $ publish new.

$ mkdir MyWebsite
$ cd MyWebsite
$ publish new

Now all the files necessary for building your website are in place. Now open the website in Xcode using $ open Package.swift.

Locally run

To check that everything runs smoothly on the terminal in the root folder of your website, run $ publish run. This will create a local server that runs it in http://localhost:8000.

Some must do changes

Go back to Xcode and open main.swift file, you'll find this:

var url = URL(string: "http://localhost:8000")!
var name = "MyWebsite"
var description = "MyWebsite Website"

If you are going to deploy this online it'll be necessary to change the URL for the one you are using. Also, the name and description may need to be change to something more meaningful.

Refer to the GitHub project for more accurate setup process and troubleshooting.

Where to deploy Publish?

There's a bunch of places where a static website can be deployed. Some of the even for free.

This particular website is hosted using Github Pages .

Other alternatives, but not limited to, are Netlify , Amazon S3 , and Render .