<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ajay Karwal</title>
    <description>The latest articles on DEV Community by Ajay Karwal (@ajaykarwal).</description>
    <link>https://dev.to/ajaykarwal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4835%2F55ae4014-75ce-4704-9372-f72b68151937.jpeg</url>
      <title>DEV Community: Ajay Karwal</title>
      <link>https://dev.to/ajaykarwal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajaykarwal"/>
    <language>en</language>
    <item>
      <title>Add spaces to the Dock in macOS</title>
      <dc:creator>Ajay Karwal</dc:creator>
      <pubDate>Tue, 04 Jun 2019 13:14:57 +0000</pubDate>
      <link>https://dev.to/ajaykarwal/add-spaces-to-the-dock-in-macos-372h</link>
      <guid>https://dev.to/ajaykarwal/add-spaces-to-the-dock-in-macos-372h</guid>
      <description>&lt;p&gt;If you want to take greater control of how apps are organised on your macOS Dock, a great way is to add spaces between groups of apps.&lt;/p&gt;

&lt;p&gt;Run this one-liner in your Terminal to create a new blank space in your Dock&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;defaults write com.apple.dock persistent-apps &lt;span class="nt"&gt;-array-add&lt;/span&gt; &lt;span class="s1"&gt;'{"tile-type"="spacer-tile";}'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; killall Dock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does is add a new ‘spacer-tile’ item to the Dock’s ‘persistent apps’ array — the list of apps which are permanently in the Dock — and then reloads the Dock.&lt;/p&gt;

&lt;p&gt;The new space will be added to the end of the Dock. Of course it’s invisible so the best way to confirm it’s there is to open any other app which isn’t currently in your Dock. You should now see a space which you can drag into the desired position.&lt;/p&gt;

&lt;p&gt;To create more spaces, just run the command again.&lt;/p&gt;

&lt;p&gt;Here is what my Dock looks like. I like to group my apps by function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe02c3gc4wv1xk7l8xxc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe02c3gc4wv1xk7l8xxc9.png" alt="macOS Dock with Spaces" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>macos</category>
      <category>dock</category>
      <category>tips</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Deploying a Jekyll website using Travis CI</title>
      <dc:creator>Ajay Karwal</dc:creator>
      <pubDate>Fri, 02 Jun 2017 08:36:39 +0000</pubDate>
      <link>https://dev.to/ajaykarwal/deploying-a-jekyll-website-using-travis-ci</link>
      <guid>https://dev.to/ajaykarwal/deploying-a-jekyll-website-using-travis-ci</guid>
      <description>&lt;p&gt;Following on from my post about &lt;a href="https://dev.to/ajaykarwal/switching-from-a-cms-to-jekyll"&gt;moving from a CMS to Jekyll&lt;/a&gt;, the next pain point to tackle is the build and deployment of your site.&lt;/p&gt;

&lt;p&gt;Jekyll does a great job of compiling your website into a neat &lt;code&gt;_site&lt;/code&gt; folder which you can then FTP to your server, however this does mean that you need to have the convenience of an FTP client at hand. A better solution would be to automate this process and seeing our source code is already being stored on GitHub, we're already half way there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet Travis
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://travis-ci.org/"&gt;Travis CI&lt;/a&gt; is a free Continuous Integration service for testing and deploying your open source GitHub projects (a paid option is available for private Github projects).&lt;/p&gt;

&lt;p&gt;Add a config file to your project, point Travis CI to your GitHub repo and when you push your code or merge a pull request, Travis CI builds your Jekyll site in a VM and deploys your code as per the settings in the config.&lt;/p&gt;

&lt;p&gt;So, let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Travis CI config file
&lt;/h2&gt;

&lt;p&gt;Create a new file in the root of your Jekyll project and name it &lt;code&gt;.travis.yml&lt;/code&gt;. As this is a 'Dotfile' it may be hidden in Finder but should appear in your text editor. The contents of this file will tell Travis CI how to build and deploy your site. This is the contents of my file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby&lt;/span&gt;
&lt;span class="na"&gt;rvm&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;2.3.1&lt;/span&gt;

&lt;span class="na"&gt;install&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bundle install&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install jekyll&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install jekyll-sitemap&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install emoji_for_jekyll&lt;/span&gt;

&lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;

&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;global&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;JEKYLL_ENV=production&lt;/span&gt;

&lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;recipients&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ajaykarwal@gmail.com&lt;/span&gt;
    &lt;span class="na"&gt;on_success&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;on_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;

&lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chmod +x _scripts/build.sh&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;_scripts/build.sh&lt;/span&gt;

&lt;span class="na"&gt;after_success&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chmod +x _scripts/deploy.sh&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;_scripts/deploy.sh&lt;/span&gt;

&lt;span class="na"&gt;sudo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="na"&gt;addons&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;apt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;packages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ncftp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break this down step-by-step&lt;/p&gt;

&lt;h3&gt;
  
  
  Define the build environment and dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby&lt;/span&gt;
&lt;span class="na"&gt;rvm&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;2.3.1&lt;/span&gt;

&lt;span class="na"&gt;install&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;bundle install&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install jekyll&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install jekyll-sitemap&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;gem install emoji_for_jekyll&lt;/span&gt;

&lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;

&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;global&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;JEKYLL_ENV=production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section tells Travis CI that the build requires Ruby and sets the version to 2.3.1. It also lists any Gem dependencies. 'jekyll-sitemap' and 'emoji_for_jekyll' are specific to my project.&lt;/p&gt;

&lt;p&gt;The branches section allows you to control which branch in your repository you want to build. In my case I am just building the master branch but this section can be used to set up a staging environment too.&lt;/p&gt;

&lt;p&gt;Setting &lt;code&gt;JEKYLL_ENV&lt;/code&gt; to production means we can test for this environment variable while doing local testing to &lt;a href="https://github.com/ajaykarwal/portfolio/blob/master/_includes/head.html#L26-L28"&gt;ignore things like Google Analytics&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building and Deploying the site
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chmod +x _scripts/build.sh&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;_scripts/build.sh&lt;/span&gt;

&lt;span class="na"&gt;after_success&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;chmod +x _scripts/deploy.sh&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;_scripts/deploy.sh&lt;/span&gt;

&lt;span class="na"&gt;sudo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="na"&gt;addons&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;apt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;packages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ncftp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section is telling Travis CI to find and execute the file located at &lt;code&gt;_scripts/build.sh&lt;/code&gt; and on success execute the file at &lt;code&gt;_scripts/deploy.sh&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The addons section tells Travis CI to also install an FTP client called ncftp. This will be used to deploy your site.&lt;/p&gt;

&lt;p&gt;Create a folder in the root called &lt;code&gt;_scripts&lt;/code&gt; and inside create a build and deploy shell script.&lt;/p&gt;

&lt;h4&gt;
  
  
  build.sh
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

bundle &lt;span class="nb"&gt;exec &lt;/span&gt;jekyll build &lt;span class="nt"&gt;--config&lt;/span&gt; _config.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The build script is essentially the same as the command you run in Terminal while building your site locally with the addition of defining the &lt;code&gt;_config.yml&lt;/code&gt; file as the site's configuration file.&lt;/p&gt;

&lt;h4&gt;
  
  
  deploy.sh
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;  &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$TRAVIS_PULL_REQUEST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"false"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;
&lt;span class="k"&gt;then
    &lt;/span&gt;ncftp &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USERNAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
    rm -rf site/wwwroot
    mkdir site/wwwroot
    quit
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;    &lt;span class="nb"&gt;cd &lt;/span&gt;_site &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit
    &lt;/span&gt;ncftpput &lt;span class="nt"&gt;-R&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$USERNAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PASSWORD&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOST&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; /site/wwwroot &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The deploy script performs 3 main tasks&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Logs into your FTP account using the &lt;code&gt;$USERNAME&lt;/code&gt;, &lt;code&gt;$PASSWORD&lt;/code&gt; and &lt;code&gt;$HOST&lt;/code&gt; variables which you set in Travis CI settings.&lt;/li&gt;
&lt;li&gt;Deletes the &lt;code&gt;site/wwwroot&lt;/code&gt; directory and recreates an empty one&lt;/li&gt;
&lt;li&gt;Copies the contents of the &lt;code&gt;_site&lt;/code&gt; folder to &lt;code&gt;/site/wwwroot&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This script was written by &lt;a href="https://jamiemagee.co.uk/2015/03/31/continuous-deployment-jekyll-to-azure/"&gt;Jamie Magee&lt;/a&gt; who provided some very helpful guidance during the whole process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Travis CI
&lt;/h2&gt;

&lt;p&gt;For the deploy script to work you need to configure the environment variables for your GitHub repository in Travis CI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go your your &lt;a href="https://travis-ci.org/profile/"&gt;Travis profile&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Find your Jekyll repository, switch Travis CI on and click the gear icon&lt;/li&gt;
&lt;li&gt;Set the Environment Variables for your FTP host.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jsbuparQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/6lbk8gsv8qakckzisg8w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jsbuparQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/6lbk8gsv8qakckzisg8w.png" alt="Travis CI Environment Settings" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: Build logs for open source projects are publicly visible so remember to keep the 'Display value in build log' option off.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Automate all the things
&lt;/h2&gt;

&lt;p&gt;Now that everything is set up and configured, its simply a case of pushing your code to your GitHub master branch. Travis CI will watch your repository for changes and automatically trigger a build. If, and only when, the build is successful, Travis CI will deploy your site to your FTP host.&lt;/p&gt;

&lt;p&gt;With a Pull Request workflow, Travis CI will run a build on the PR and only when it is successful will it allow the branch to be merged into master.&lt;/p&gt;

&lt;p&gt;The notifications section in &lt;code&gt;.travis.yml&lt;/code&gt; file can be used to manage who receives build status email notifications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;notifications&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;recipients&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ajaykarwal@gmail.com&lt;/span&gt;
    &lt;span class="na"&gt;on_success&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;on_failure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Deploying your Jekyll website using Travis CI is simple, fast and secure. The Pull Request workflow is perfect for collaborating on open source projects or simply scheduling your own content by merging branches when you're ready.&lt;/p&gt;

&lt;p&gt;All of the build process is handled by Travis CI which means you can commit changes to your repository from anywhere, have your code tested and validated and then merge to push your content live. I use this method for making site updates from my phone via the GitHub website.&lt;/p&gt;

&lt;p&gt;For more ways to use Travis CI to suit your needs check out the &lt;a href="https://docs.travis-ci.com/"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>jekyll</category>
      <category>travis</category>
      <category>ci</category>
      <category>devops</category>
    </item>
    <item>
      <title>Switching from a CMS to Jekyll</title>
      <dc:creator>Ajay Karwal</dc:creator>
      <pubDate>Tue, 11 Apr 2017 08:29:14 +0000</pubDate>
      <link>https://dev.to/ajaykarwal/switching-from-a-cms-to-jekyll</link>
      <guid>https://dev.to/ajaykarwal/switching-from-a-cms-to-jekyll</guid>
      <description>&lt;p&gt;Back in February, I shipped a new version of my website. Only a very slight update to the design but a complete overhaul on how it was built.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-829825398385082368-890" src="https://platform.twitter.com/embed/Tweet.html?id=829825398385082368"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-829825398385082368-890');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=829825398385082368&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Everything was originally built using &lt;a href="https://umbraco.com/" rel="noopener noreferrer"&gt;Umbraco&lt;/a&gt; – a CMS powered by .NET – and hosted on Microsoft Azure. This setup of course was reliant on Windows for developement.&lt;/p&gt;

&lt;p&gt;I'm a Mac user so in order for me to update my website I needed to run Windows in VMmare Fusion, fire up the project in Visual Studio, setup my localhost and IIS Express, log into the Umbraco dashboard and then make my updates. &lt;/p&gt;

&lt;p&gt;When it came to deploying my changes, I would then have to FTP my Views, DocumentTypes (Templates), DataTypes, DLLs and static assets.&lt;/p&gt;

&lt;p&gt;Just kill me now. 😭&lt;/p&gt;

&lt;h2&gt;
  
  
  Up steps Jekyll
&lt;/h2&gt;

&lt;p&gt;I first heard about &lt;a href="https://jekyllrb.com/" rel="noopener noreferrer"&gt;Jekyll&lt;/a&gt; and other SSGs on the &lt;a href="http://www.toolsday.io/episodes/static-site-gens.html" rel="noopener noreferrer"&gt;Toolsday podcast&lt;/a&gt; (exactly one year before I launched my site update) and it had been on my &lt;em&gt;'things-I-want-to-try-one-day'&lt;/em&gt; list ever since.&lt;/p&gt;

&lt;p&gt;I started by creating a blank Jekyll site.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jekyll new myblog &lt;span class="nt"&gt;--blank&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you follow the &lt;a href="https://jekyllrb.com/docs/quickstart/" rel="noopener noreferrer"&gt;quick-start guide&lt;/a&gt; you end up with a simple blog theme which I didn't want as I was going to be importing my existing design.&lt;/p&gt;

&lt;p&gt;The problem with this process is that the command &lt;code&gt;bundle exec jekyll serve&lt;/code&gt; won't work as the installation doesn't have a &lt;code&gt;Gemfile&lt;/code&gt; or a &lt;code&gt;_config.yml&lt;/code&gt; file. More on this later.&lt;/p&gt;

&lt;p&gt;Once installed, Jekyll creates the basic folder structure required to organise your site.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── _drafts
├── _layouts
├── _posts
└── index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how the folders begin with an underscore. Any folders named this way are not outputted to the compiled &lt;code&gt;_site&lt;/code&gt; folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrating my content
&lt;/h2&gt;

&lt;p&gt;I started by coping over all my Views from my Umbraco project into my Jekyll &lt;code&gt;_layouts&lt;/code&gt; folder. Luckily both systems use similar concepts of layout templates, page templates and partial views (&lt;code&gt;_includes&lt;/code&gt; in Jekyll), so it was relatively painless to get my file structure right.&lt;/p&gt;

&lt;p&gt;Next I converted my View logic from C#/Razor into &lt;a href="https://shopify.github.io/liquid/" rel="noopener noreferrer"&gt;Liquid&lt;/a&gt;, the templating engine that Jekyll uses (which was developed by Shopify). All of the logic has a like-for-like replacement as my site wasn't doing anything too complex.&lt;/p&gt;

&lt;p&gt;Jekyll has Sass pre-processing built in so it was just a case of copying over my sass folder and adding an underscore to have it ignored from the build. I continued to add the remainder of my assets, includes and templates. You can see the full site structure on my &lt;a href="https://github.com/ajaykarwal/portfolio" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the magic happens
&lt;/h2&gt;

&lt;p&gt;The most important files you will need to create are a &lt;code&gt;Gemfile&lt;/code&gt; and a &lt;code&gt;_config.yml&lt;/code&gt; file in your project root.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Gemfile&lt;/code&gt; lists any Ruby Gems which are needed to build your project. At the very least this file should contain,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="s1"&gt;'https://rubygems.org'&lt;/span&gt;
&lt;span class="n"&gt;gem&lt;/span&gt; &lt;span class="s1"&gt;'jekyll'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;_config.yml&lt;/code&gt; file is where the magic happens. It contains all the site settings and you can add any custom settings which are then available to your liquid templates using &lt;code&gt;{% raw %}{{ site.SETTING_NAME }}{%&lt;/code&gt;&lt;code&gt;endraw&lt;/code&gt;&lt;code&gt;%}&lt;/code&gt;. You can use &lt;a href="https://github.com/ajaykarwal/portfolio/blob/master/_config.yml" rel="noopener noreferrer"&gt;my config file&lt;/a&gt; as a template for your own project or follow the &lt;a href="https://jekyllrb.com/docs/configuration/" rel="noopener noreferrer"&gt;Jekyll documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building your static site
&lt;/h2&gt;

&lt;p&gt;Now that the basic file and folder structure is in place, simply run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle exec jekyll serve --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will bundle any Ruby Gems defined in your &lt;code&gt;Gemfile&lt;/code&gt;, generate your static files to a &lt;code&gt;_site&lt;/code&gt; folder, serve up your site on &lt;code&gt;localhost:4000&lt;/code&gt; and watch for any changes you make from now on.&lt;/p&gt;

&lt;p&gt;That's it, you're done.&lt;/p&gt;

&lt;p&gt;Congratulations on converting your CMS driven website to a static website powered by Jekyll. 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Overall the process of moving from Umbraco to Jekyll was relatively simple. The documentation is very clear and there is plenty of support available on Stack Overflow for scenarios where custom logic is required in your Liquid templates.&lt;/p&gt;

&lt;p&gt;Every use case is going to be different so take this with a pinch of salt, but the over-arching pros and cons which I feel would apply to all are:&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The output is just static HTML, CSS and JavaScript so the resulting site loads extemely fast. It can also take advantage of browser caching to make return visits even more rapid.&lt;/li&gt;
&lt;li&gt;No complex hosting package or server-side processing is required which could dramatically reduce the cost of running your website. You can even host it for free via &lt;a href="https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Writing your content in Markdown results in clean, semantic markup and encourages a more structured approach to your content.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;There is a dependency of using the command-line to generate your site each time you make an edit, so some development expertise is needed. This means Jekyll is probably not a great solution for a client project where content is being managed by the client themselves.&lt;/li&gt;
&lt;li&gt;Not really suited for sites which are updated very frequently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;I would highly recommend that you try out Jekyll. Set up a test project and get a feel for how the content is structured. The Liquid templating engine is a joy to work with and has a very low barrier to entry.&lt;/p&gt;

&lt;p&gt;If you're using Jekyll for your website, I'd love to hear about your experiences.&lt;/p&gt;

</description>
      <category>jekyll</category>
      <category>cms</category>
      <category>tutorial</category>
      <category>staticsite</category>
    </item>
  </channel>
</rss>
