2015-12-19 14:52:17 +01:00
|
|
|
title: GitHub Pages
|
|
|
|
---
|
2016-02-11 01:13:37 +01:00
|
|
|
summary: Deploys to GitHub Pages.
|
2015-12-19 14:52:17 +01:00
|
|
|
---
|
|
|
|
body:
|
|
|
|
|
|
|
|
* `ghpages://username/repository`
|
|
|
|
* `ghpages+https://username/repository`
|
|
|
|
|
|
|
|
A popular way to host websites for Open Source projects is the GitHub pages.
|
2015-12-23 16:11:23 +01:00
|
|
|
It's a free service provided by [GitHub :ext](http://github.com/) which allows
|
2015-12-19 14:52:17 +01:00
|
|
|
to host completely static websites through GitHub.
|
|
|
|
|
|
|
|
The way this is implemented in Lektor currently is that Lektor will force-push
|
|
|
|
a website into a repository of choice. There are two ways to push it up:
|
|
|
|
`ghpages` (which uses SSH) or `ghpages+https` (which uses HTTPS). The latter
|
|
|
|
can also accept `username:password@` in the URL to hold the credentials in
|
2015-12-19 19:07:03 +01:00
|
|
|
addition to accepting username and password from the command line or
|
|
|
|
environment variables.
|
2015-12-19 14:52:17 +01:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```ini
|
2015-12-19 19:07:03 +01:00
|
|
|
[servers.ghpages]
|
2015-12-19 14:52:17 +01:00
|
|
|
target = ghpages://your-user/your-repository
|
|
|
|
```
|
|
|
|
|
2015-12-19 19:07:03 +01:00
|
|
|
## Credentials
|
|
|
|
|
|
|
|
This deployment method has two implementations: `ghpages` (also known as
|
|
|
|
`ghpages+ssh`) which uses SSH and `ghpages+https` which uses HTTPS. They
|
|
|
|
use different methods for credentials. For the SSH transport the same
|
|
|
|
rules apply as for the [rsync deployment method :ref](../rsync/). The HTTPS
|
|
|
|
transport on the other hand accepts `--username` and `--password` which
|
|
|
|
override the values in the URL.
|
|
|
|
|
2015-12-19 14:52:17 +01:00
|
|
|
## Behavior
|
|
|
|
|
|
|
|
The way this deployment support works is that it commits a new commit into a
|
|
|
|
temporary location and pushes it into the `gh-pages` or `master` branch
|
|
|
|
depending on the name of the repository. If you push to `username.github.io`
|
|
|
|
then it commits to `master`, otherwise to `gh-pages`. This is consistent
|
|
|
|
with behavior for GitHub Pages.
|
|
|
|
|
|
|
|
## CNAME Support
|
|
|
|
|
2016-11-28 09:19:46 +01:00
|
|
|
If you want to use a custom domain with GitHub pages (also known as a
|
|
|
|
[CNAME :ext](https://en.wikipedia.org/wiki/CNAME)), provide the intended
|
|
|
|
CNAME in the target URL using the `?cname` parameter:
|
2015-12-19 14:52:17 +01:00
|
|
|
|
|
|
|
```ini
|
|
|
|
[servers.production]
|
|
|
|
target = ghpages://your-user/your-repository?cname=www.example.com
|
|
|
|
```
|
|
|
|
|
2016-11-28 09:19:46 +01:00
|
|
|
Note that this will overwrite whatever custom domain you may have set on
|
|
|
|
GitHub with every deployment.
|
2016-11-16 08:22:13 +01:00
|
|
|
|
2015-12-19 14:52:17 +01:00
|
|
|
For more information about how CNAMEs work with GitHub you can read about
|
|
|
|
the feature in the GitHub help center:
|
|
|
|
[Adding a CNAME file to your repository
|
|
|
|
:ext](https://help.github.com/articles/adding-a-cname-file-to-your-repository/).
|
|
|
|
|
|
|
|
## 404 Pages
|
|
|
|
|
2016-02-11 01:13:37 +01:00
|
|
|
Per convention the file named `404.html` is used as placeholder if a page
|
2015-12-19 14:52:17 +01:00
|
|
|
cannot be found. You can create such a page by creating a `404.html/contents.lr`
|
|
|
|
file.
|
|
|
|
|
|
|
|
## Automatic Deployments
|
|
|
|
|
|
|
|
If you want to use ghpages it's desirable to have this build automatically.
|
|
|
|
This is easy to accomplish with the help of Travis-CI. For more information
|
|
|
|
see [Deploying with Travis-CI :ref](../travisci/).
|