on master help sign in
Adds introduction and fixed formatting issues
03dbc4eerik
web/tutorials/github-pages-tutorial.md+30−37
@@ -1,5 +1,16 @@
1## Using Hakyll with GitHub Pages
1## Using Hakyll with GitHub Pages
2
2
3+[GitHub Pages](http://pages.github.com) has become a popular static website hosting solution due to its simplicity. Simply push a couple files to a repository and it's off to the races.
4+
5+Working with Hakyll on a GitHub Pages-hosted website is complicated slightly due to Hakyll outputting files to a ```_site``` subdirectory, our desire to have the source code as well as the compiled site stored in a single repository, and our desire to automate it.
6+
7+This guide will walkthrough the creation and setup of a GitHub site that has two independent branches.
8+
9+1. ```master``` - This is where your site lives. It's what you see when you go to ```https://<your repo>.github.io```. This branch *needs* to be called master.
10+2. ```develop``` - This is where your website's source is. That's all your Haskell code, your posts and templates, etc, and it's where you do work from. This name was chosen arbitrarily and can be freely substituted for any name of your choosing.
11+
12+When you're finished, you will be able to, with one command, refresh your website's contents and send any changes to your GitHub Page.
13+
3In the interest of keeping this guide as simple as possible, I'll be making a few assumptions.
14In the interest of keeping this guide as simple as possible, I'll be making a few assumptions.
4
15
51. Haskell is being used with [Stack](http://docs.haskellstack.org/en/stable/README/).
161. Haskell is being used with [Stack](http://docs.haskellstack.org/en/stable/README/).
@@ -50,11 +61,15 @@ So everything's all setup and we're ready to deploy.
50
61
51Temporarily save any uncommitted changes that may exist in the current branch.
62Temporarily save any uncommitted changes that may exist in the current branch.
52
63
64+```
53−```git stash```
65+git stash
66+```
54
67
55Ensure we are in the correct branch.
68Ensure we are in the correct branch.
56
69
70+```
57−```git checkout develop```
71+git checkout develop
72+```
58
73
59Get a clean build of our site.
74Get a clean build of our site.
60
75
@@ -65,15 +80,21 @@ stack exec myblog build
65
80
66Update the local list of remote branches to ensure we're able to checkout the branch we want in the next step.
81Update the local list of remote branches to ensure we're able to checkout the branch we want in the next step.
67
82
83+```
68−```git fetch -all```
84+git fetch -all
85+```
69
86
70Switches to a new branch called "publish" that tracks the origin "master" branch. **Note:** Checking out the publish branch does not overwrite the files that Hakyll just produced because we have '_site' in both .gitignore files.
87Switches to a new branch called "publish" that tracks the origin "master" branch. **Note:** Checking out the publish branch does not overwrite the files that Hakyll just produced because we have '_site' in both .gitignore files.
71
88
89+```
72−```git checkout -b publish --track origin/master```
90+git checkout -b publish --track origin/master
91+```
73
92
74Copy the freshly made contents of '_site' over the old ones. Note that if a file is *no longer* being produced (for example if you deleted a blog posting), it will continue to persist in your published site until it's been removed from that repository as well.
93Copy the freshly made contents of '_site' over the old ones. Note that if a file is *no longer* being produced (for example if you deleted a blog posting), it will continue to persist in your published site until it's been removed from that repository as well.
75
94
95+```
76−```cp -a _site/. .```
96+cp -a _site/. .
97+```
77
98
78Commit our changes.
99Commit our changes.
79
100
@@ -84,7 +105,9 @@ git commit -m "publish."
84
105
85And send them to GitHub.
106And send them to GitHub.
86
107
108+```
87−```git push origin publish:master```
109+git push origin publish:master
110+```
88
111
89Final clean up and return to the original state.
112Final clean up and return to the original state.
90
113
@@ -96,35 +119,5 @@ git stash pop
96
119
97### *And that's it.*
120### *And that's it.*
98
121
99−Here is a full listing of the script.
122+A full listing of the "script" is available [here](https://gist.github.com/narrative/5edb976b2f8754a79104).
100
123
101−```
102−# Temporarily store uncommited changes
103−git stash
104−
105−# Verify correct branch
106−git checkout develop
107−
108−# Build new files
109−stack exec myblog clean
110−stack exec myblog build
111−
112−# Get previous files
113−git fetch -all
114−git checkout -b publish --track origin/master
115−
116−# Overwrite existing files with new files
117−cp -a _site/. .
118−
119−# Commit
120−git add -A
121−git commit -m "publish."
122−
123−# Push
124−git push origin publish:master
125−
126−# Restoration
127−git checkout develop
128−git branch -D publish
129−git stash pop
130−```