-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.xml
129 lines (86 loc) · 13.7 KB
/
feed.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Mel Lota</title>
<description>Web development, Code Exploration and Raspberry Pi Hacking</description>
<link>http://mlota.github.io/</link>
<atom:link href="http://mlota.github.io/feed.xml" rel="self" type="application/rss+xml"/>
<pubDate>Tue, 24 Nov 2015 09:03:32 +0000</pubDate>
<lastBuildDate>Tue, 24 Nov 2015 09:03:32 +0000</lastBuildDate>
<generator>Jekyll v3.0.1</generator>
<item>
<title>Automating deployment of a GitHub Pages hosted site with Jekyll and Travis CI</title>
<description><p>Earlier this month I set up this blog using the simple publishing mechanism provided by GitHub Pages and Jekyll. It all works perfectly, but as I began to delve deeper into Jekyll, I discovered that it’s possible to create a more efficient deployment workflow using Travis CI and GitHub. I’m a big advocate of continuous deployment and build automation so I had to check this out.</p>
<p>I also decided to move away from using the out-of-the-box build process that GitHub Pages provides for Jekyll. This is mainly due to the added flexibility of using custom plugins, as GitHub Pages runs in <code class="highlighter-rouge">--safe</code> mode it effectively disables this feature. I found it wasn’t too difficult to get this all setup, but it does mean that you’ll need a local development environment with Ruby and Jekyll installed.</p>
<h2 id="development-environment">Development Environment</h2>
<p>I’m using a Macbook Pro with OSX - El Capitan (ridiculous name btw) so I started out by grabbing a copy of the following:</p>
<ul>
<li><a href="http://brew.sh/">Homebrew</a> - A super-simple software package manager for the Mac. I found it was a bit like Chocolatey on Windows.</li>
<li><a href="https://github.com/sstephenson/rbenv">rbenv</a> - I had to use this in order to install the latest version of Ruby (2.2.3 at the time of writing) without affecting the system installed version.</li>
<li><a href="http://bundler.io/">Bundler</a> - This helps to manage Gem dependencies when working Ruby. I also like to set it up so that it installs required gems to the project directory to avoid clutter elsewhere</li>
</ul>
<p>I cloned a copy of the current, GitHub Pages oriented site down to my local machine and created a <code class="highlighter-rouge">Gemfile</code> to add the Jekyll dependencies:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="n">source</span> <span class="s2">"https://rubygems.org"</span>
<span class="n">gem</span> <span class="s2">"jekyll"</span>
<span class="n">gem</span> <span class="s2">"jekyll-paginate"</span></code></pre></figure>
<p>I then ran the following command to install the gems into a <strong>vendor</strong> folder in the root of the project directory:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="gp">$ </span>bundler install --path vendor</code></pre></figure>
<p>I also created a simple shell script to serve the site locally:</p>
<p><strong>serve.sh</strong></p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="c">#!/usr/bin/env bash</span>
<span class="nb">set</span> -e <span class="c"># halt script on error</span>
bundle <span class="nb">exec </span>jekyll serve --config _config.yml,_config_dev.yml --watch</code></pre></figure>
<p>There are a few interesting things going on here which I’ll elaborate on. Firstly it’s worth mentioning that by default the site will be served on port 4000, so you’ll be able to use your browser and navigate to <a href="http://localhost:4000">http://localhost:4000</a>. I’m also supplying the <code class="highlighter-rouge">jekyll serve</code> command with two arguments:</p>
<ul>
<li><code class="highlighter-rouge">--config</code> accepts a comma separated list of site config files. Whichever file comes last in the list will override any settings in the preceding file. I’m using this so that I can set a separate <strong>baseurl</strong> for dev, so that any global links work when I’m serving the site locally.</li>
<li><code class="highlighter-rouge">--watch</code> tells Jekyll to watch for any file changes in the project directory, and automatically regenerate the site</li>
</ul>
<h2 id="automated-deployment">Automated Deployment</h2>
<p>Next up was automating the deployment of the site files to GitHub Pages. <a href="https://travis-ci.org">Travis CI</a> is an online, continuous integration service used for building and testing code. I’m new to Travis, but I frequently use other CI tools such as Jenkins and TeamCity so the concepts were familiar. One nice thing about Travis is that it is completely free to use on public source code repositories, so it’s ideal for a small project such as this blog.</p>
<p>For setting up the automated deployment, I used the following article as a reference point:</p>
<blockquote>
<p><a href="http://eshepelyuk.github.io/2014/10/28/automate-github-pages-travisci.html">Automate GitHub Pages publishing with Jekyll and Travis CI</a></p>
</blockquote>
<p>It roughly consists of performing the following steps</p>
<ul>
<li>Set up a new branch to contain the Jekyll source code and use the master branch to host the cleanly built site code</li>
<li>Enabling Travis hook for the repository</li>
<li>Create a personal access token in GitHub</li>
<li>Creating a .travis.yml and build.sh file</li>
<li>Running the build</li>
</ul>
<p>I won’t go into too much detail about these points here, as the article is quite concise. I did however run into a minor issue with permissions on the <code class="highlighter-rouge">build.sh</code> file when I first tried running a build in Travis. After a bit of research I found this was due to the file requiring ‘execute’ permissions and could be easily remedied by adding a <code class="highlighter-rouge">chmod</code> command to the <code class="highlighter-rouge">.travis.yml</code> file:</p>
<figure class="highlight"><pre><code class="language-yaml" data-lang="yaml"><span class="s">before_script</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">chmod +x "./build.sh"</span></code></pre></figure>
<h2 id="enhancements">Enhancements</h2>
<p>With Travis in place, enabling test scripts in the build process becomes quite a trivial task. I added the following enhancements…</p>
<h3 id="html-proofer">HTML proofer</h3>
<p>The <a href="https://github.com/gjtorikian/html-proofer">html-proofer</a> Gem provides a set of tools for running checks on validity of links and images across a Jekyll generated site. I implemented this by adding the <code class="highlighter-rouge">html-proofer</code> Gem to the Gemfile and the following line to the <code class="highlighter-rouge">build.sh</code> file:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">bundle <span class="nb">exec </span>htmlproof ./_site --disable-external --check-html --verbose</code></pre></figure>
<p>With the optional arguments in that command, I am disabling the check for external links, checking the output files for valid HTML and outputting verbose results to the console.</p>
<h3 id="html-beautifier">HTML Beautifier</h3>
<p>Seeing as I have a touch of OCD, I like to keep the HTML output on my sites tidy and indented correctly. This is somewhat difficult to accomplish when working with Jekyll as the various includes and liquid templating leave unwanted spacing and indentation. I came across a Gem called <a href="https://github.com/threedaymonk/htmlbeautifier">htmlbeautifier</a> which takes an input file and outputs a nicely indented HTML document. The documentation is a little sparse for this one, so I had to figure out how to run this for all the HTML files in the <code class="highlighter-rouge">_site</code> directory. I came up with the following command which can be added <code class="highlighter-rouge">build.sh</code> file and seems to work perfectly:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash">find ./_site -name <span class="s2">"*.html"</span> -exec bundle <span class="nb">exec </span>htmlbeautifier <span class="o">{}</span> <span class="se">\;</span></code></pre></figure>
<h2 id="summary">Summary</h2>
<p>Switching from the standard GitHub Pages build process to Travis is not as daunting as it seems and I’ve certainly learnt a fair bit about Ruby and bash scripts along the way. Going forward, I’d like to look at other ways I can optimse the site during the build process such as minifying scripts. All of the code I’ve spoken about in this article is free to view on the <a href="https://github.com/mlota/mlota.github.io/tree/source">GitHub repository for this blog</a>. Hope this comes in handy for anyone looking to improve their Jekyll blog deployment :)</p>
</description>
<pubDate>Mon, 23 Nov 2015 00:00:00 +0000</pubDate>
<link>http://mlota.github.io/2015/11/23/automating-deployment-github-pages-jekyll-travis.html</link>
<guid isPermaLink="true">http://mlota.github.io/2015/11/23/automating-deployment-github-pages-jekyll-travis.html</guid>
</item>
<item>
<title>A New Blog!!</title>
<description><p>I’ve been putting this off for some time now, but I’ve finally bit the bullet and got a blog up and running :-) Over the last year I’ve been working on a number of development projects in both my professional and personal life that I’d like to share with the community.</p>
<p>Having previously tried various blogging platforms such as Wordpress and Blogger, I decided that what I really need is something very simple so that I can focus on content. After hearing a lot of buzz recently about static site generators, I got inspired to try <a href="https://jekyllrb.com/">Jekyll</a> and <a href="https://pages.github.com/">GitHub Pages</a>.<br />
The nice thing about this setup is that hosting on Github is free, providing that the codebase for the blog repository is public.</p>
<p>I began by forking a nice looking example called <a href="https://github.com/daattali/beautiful-jekyll">Beautiful Jekyll</a> by <a href="https://github.com/daattali">Dean Atalli</a>. It’s a really good starting point as it’s easily configurable and includes some basic layouts and sample posts. When hosting with GitHub pages, it’s as simple as adding a new page to the repository and the site will automatically rebuild.</p>
<p>Another nice thing I discovered is that there is a free to use service called <a href="http://prose.io">Prose</a> which hooks into the GitHub repository and provides a CMS-style editor for writing your posts. It has a very clean and easy to use interface which allows previewing and saving posts as drafts.</p>
<p>I’m reasonbly new to using Git with the command line. I’d previously been using Mercurial with BitBucket and TortoiseHG. I found an excellent online tutorial on <a href="https://try.github.io/levels/1/challenges/1">try.github.io</a> which is around 15 minutes long and takes you through all the basics. I’d highly recommend this if you’re new to Git.</p>
<p>My aim is to get into a regular practice of blogging about stuff I’m working on and sharing anything useful I come across. Thanks for visiting, there’ll be more posts to follow!</p>
</description>
<pubDate>Wed, 04 Nov 2015 00:00:00 +0000</pubDate>
<link>http://mlota.github.io/2015/11/04/a-new-blog-first-steps-with-jekyll.html</link>
<guid isPermaLink="true">http://mlota.github.io/2015/11/04/a-new-blog-first-steps-with-jekyll.html</guid>
</item>
</channel>
</rss>