Quick start with sourcehut pages

The steps for publishing your site are:

  1. Generate a personal access token
  2. Create a tarball with your website’s contents.
  3. Upload your tarball to pages.sr.ht

Once you’re live, we’ll look at ways to automate the process.

Your personal access token

You can generate a personal access token on meta.sr.ht. Write it down for later reference.

Building your tarball

Here’s a simple example. Let’s say you write this file to index.html:

<!doctype html>
<html lang="en">
<meta charset="utf-8" />
<title>My sourcehut page</title>
<h1>My sourcehut page</h1>
<p>Welcome to my cool sourcehut page!

You can create a tarball for it like so:

$ tar -cvz index.html > site.tar.gz

Add any number of files other than index.html to expand this.

Using a static site generator

Here’s another example for a website using Hugo:

$ hugo
$ tar -C public -cvz . > site.tar.gz

You can use any tool, just so long as it outputs static content.

Uploading your tarball

Once you have a tarball, upload it to pages.sr.ht:

$ curl --oauth2-bearer "access token" \
    -Fcontent=@site.tar.gz \
    https://pages.sr.ht/publish/username.srht.site

Substitute “access token” with your personal access token, and username with your sr.ht username.

Want to use your own domain name? Review the extra steps here.

Once you run this command, your website should now be live at https://username.srht.site! The first load will take an extra second or two while we obtain a TLS certificate for you.

Need some help building your site? Hugo is a good choice for getting up and running quickly with a nice theme for your site. We recommend it for users new to static site generation. Feel free to set up a site you like, then come back when you're ready to publish it.

Hugo Quick Start

Next: Automating deployments

Next: Automating deployments