Building

go run main.go --build

This command will build all of your static assets and place them in /out.

Godocument will take all the relative paths you use during development and modify them into absolute paths for production.

Using relative paths during development is a requirement. Not doing so will result in unexpected behaviour when building.

Providing an Absolute Path

When you are ready to build your site for production, you will need to provide an absolute path.

go run main.go --build <absolute-path>

If an absolute path is not provided, Godocument will serve your assets on whatever port 8080. This is useful for testing your application prior to deployment. If you do provide an absolute path, Godocument will not serve the assets locally.

For example, let's say I wanted to build for godocument.dev, I would run:

go run main.go --build godocument.dev

Absolute paths should not include a '/' at the end, this will result in a panic.

Bundling Stylesheets

Godocument will bundle your stylesheets to reduce the number of network calls needed on the initial page load. During development, two network calls are made to introduce styling into your pages. Let's look at the <head> links in /html/templates/base.html:

<link rel="stylesheet" type="text/css" href="/static/css/index.css">
<link rel="stylesheet" type="text/css" href="/static/css/output.css">

After bundling, these will be converted into:

<link rel="stylesheet" type="text/css" href="/<absolute-path>/static/css/index.css">

The vanilla CSS will be stacked on top of the Tailwind CSS, giving Tailwind priority.

Minification

Godocument uses Minify to compress and minify static assets, which helps to reduce the file sizes of HTML, CSS, and Javascript files. These optimizations improves loading times and bandwidth usage in production.