Publishing docs — all chapters

What GitHub Pages is for

GitHub Pages serves a website from a GitHub repository, free, on a github.io address or your own domain. Selfish commits your built site into a repository and Pages serves it. Each publish is one commit, so you get the whole history of your site, and you can always go back.

No git is needed on your device. Selfish makes the commit through GitHub’s API.

In Site Settings → Publishing, set Publish Using to GitHub Pages. There are two ways to give Selfish access: sign in, or paste a token.

Sign in with GitHub

This is the short way. There is no token to copy.

  1. Make a repository for your site at github.com/new, or decide which existing one to use. Create a Repository in Selfish opens that page. Selfish can’t create a repository for you.
  2. Choose Sign In with GitHub. Selfish shows a short code.
  3. Choose Copy Code and Open GitHub. Paste the code on GitHub’s page and approve Selfish. Then come back. The app carries on by itself.
  4. Choose Choose Repositories on GitHub and give Selfish the repository for your site. Selfish can reach only the repositories you choose there, and nothing else in your account.
  5. Back in Selfish, pick the repository from the list. If it is the only one, it is chosen for you.

Then publish. Selfish commits the site, and turns GitHub Pages on for you if it is off, serving the branch it published to.

What signing in allows is narrow. Selfish may read and write the contents of the repositories you chose, and switch Pages on for them. It can’t see your other repositories or create new ones. The sign-in is kept in the Keychain like every other secret, it renews itself as you publish, and Sign Out ends it.

With an access token

If you would rather not sign in, choose Use an Access Token Instead.

  1. Fill in Owner and Repository.
  2. Choose Create Token on GitHub. It opens GitHub’s form for a fine-grained token with the right permission already selected.
  3. On GitHub, choose Only select repositories, pick this repository, generate the token, and paste it into Access Token.
  4. Publish once. Then turn Pages on in the repository’s Settings → Pages, choosing the branch, and the folder, you published to.

The token needs one permission: Contents, read and write, on this repository. If you give it an expiry date, it stops working on that date, and you paste in a new one. A token with only that permission can’t read the repository’s Pages settings, so the checks described under Test Connection below work when you are signed in.

The fields

FieldWhat to enter
OwnerThe user or organisation that owns the repository, for example octocat. Chosen for you when you pick from the list.
RepositoryThe repository’s name, for example my-site.
BranchOptional. Leave it empty for gh-pages. Selfish creates the branch on the first publish if it doesn’t exist.
SubdirectoryOptional. A folder to publish into, such as docs. Empty means the top of the branch. This choice changes how publishing behaves, as below.

A brand-new, empty repository is fine. Selfish starts it with a short README so there is something to build on.

Two ways to lay it out

With no subdirectory, the branch becomes exactly your site. Each publish replaces what was there, so anything you removed since last time disappears on its own. Use a branch kept for the purpose, which is what the default gh-pages is.

With a subdirectory, Selfish publishes into that folder and leaves everything else in the branch untouched. That is the setup for serving Pages from /docs on your main branch, beside other files.

GitHub Pages can serve a branch from its top or from a folder called docs, and nothing else, so a subdirectory with any other name is one Pages won’t serve.

Either way:

Test Connection

Test Connection proves the access and the repository in one go. When you are signed in, so that Selfish may read the repository’s Pages settings, it also notices when everything connects but the site still wouldn’t show, and says what to change:

Things to know

Your own domain

With your own domain as the site’s address, Selfish’s Publishing screen shows the DNS records GitHub needs and checks them from your device. See Custom domains.

Problems? See Troubleshooting.