<?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: Deborah D</title>
    <description>The latest articles on DEV Community by Deborah D (@deborahd).</description>
    <link>https://dev.to/deborahd</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%2F18840%2Fd6d5f6c2-bf9a-4971-a859-16a7795b3dae.png</url>
      <title>DEV Community: Deborah D</title>
      <link>https://dev.to/deborahd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deborahd"/>
    <language>en</language>
    <item>
      <title>Gatsby Up &amp; Running: Creating a CD Pipeline</title>
      <dc:creator>Deborah D</dc:creator>
      <pubDate>Sat, 26 Sep 2020 18:36:02 +0000</pubDate>
      <link>https://dev.to/deborahd/gatsby-up-running-creating-a-cd-pipeline-2p7m</link>
      <guid>https://dev.to/deborahd/gatsby-up-running-creating-a-cd-pipeline-2p7m</guid>
      <description>&lt;p&gt;My &lt;a href="https://deborah-digges.github.io/2020/09/16/Jekyll-to-Gatsby"&gt;last adventure&lt;/a&gt; was migrating my crufty Jekyll site to Gatsby. I used to deploy my Jekyll site manually by building it locally and pushing the generated static content to the &lt;code&gt;gh-pages&lt;/code&gt; branch on GitHub. With my new site in place, I decided it was time to leave my old ways behind and set up an automated pipeline to deploy my site to GitHub pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why GitHub Pages?
&lt;/h2&gt;

&lt;p&gt;I've always used GitHub Pages to host my blog because it's lightweight and integrates seamlessly with GitHub. It is simple, free, and provides free goodies like enforcing HTTPS by default and also supports adding a custom domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying Locally
&lt;/h2&gt;

&lt;p&gt;Before automating the deployment of my new Gatsby site, I learned how to deploy it locally. To do this, I added an entry to the &lt;code&gt;scripts&lt;/code&gt; tag in &lt;code&gt;package.json&lt;/code&gt; which creates a production-ready build for my Gatsby site.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  ...
  "build": "gatsby build",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;p&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 builds the site and places the generated assets in a folder called &lt;code&gt;public&lt;/code&gt;. Copying this &lt;code&gt;public&lt;/code&gt; folder to any HTTP server would deploy my site to that server.&lt;/p&gt;

&lt;p&gt;I started an HTTP server using &lt;a href="https://www.npmjs.com/package/http-server"&gt;http-server&lt;/a&gt; to serve the assets in the &lt;code&gt;public&lt;/code&gt; folder which effectively deployed my site locally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;➜  cd public
➜  http-server
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8082
  http://10.10.10.10:8082
  http://192.168.13.12:8082
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Deploying Manually to Github Pages
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting up Github Pages
&lt;/h3&gt;

&lt;p&gt;I already had GitHub pages set up since I used it for my Jekyll site but I will go over the steps here for completeness.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xvQwTA9P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y25t3rw5rtm22galrt93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xvQwTA9P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y25t3rw5rtm22galrt93.png" alt="Github Repository" width="880" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I headed to my GitHub repository's settings page and scrolled down to the &lt;code&gt;GitHub Pages&lt;/code&gt; section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pzDEoNNI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9nb6m9cs8mviym4xo5hk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzDEoNNI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9nb6m9cs8mviym4xo5hk.png" alt="Alt Text" width="880" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I did not want the files generated by the Gatsby build process to clutter up my &lt;code&gt;master&lt;/code&gt; branch so I chose the &lt;code&gt;gh-pages&lt;/code&gt; branch as the source branch for my GitHub Pages site. Any static site I pushed to this branch would then be published at &lt;code&gt;deborah-digges.github.io&lt;/code&gt;. I also liked the fact that &lt;code&gt;Enforce HTTPS&lt;/code&gt; was enabled by default. All the security!&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying Manually
&lt;/h3&gt;

&lt;p&gt;I deployed the site manually to GitHub Pages by building the site locally and pushing &lt;em&gt;only&lt;/em&gt; the &lt;code&gt;public&lt;/code&gt; folder to the &lt;code&gt;gh-pages&lt;/code&gt; branch on GitHub.&lt;/p&gt;

&lt;p&gt;This required a rather awkward sequence of commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b gh-pages

gatsby build

# Temporarily move the public folder
mv public /tmp

# Remove all other files
rm -r *

# Move the contents of the public folder back to the root of the directory
cp -r  /tmp/public/* .

git commit -m "Release new version of blog"

git push origin gh-pages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a mouthful and it's easy to go and accidentally nuke your whole computer with commands like &lt;code&gt;rm -r *&lt;/code&gt;. It's a good thing the &lt;a href="https://www.npmjs.com/package/gh-pages"&gt;gh-pages&lt;/a&gt; package exists to save us from ourselves.&lt;/p&gt;

&lt;p&gt;I added the dependency to my project to give it a spin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add gh-pages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To let &lt;code&gt;gh-pages&lt;/code&gt; know where my repository was located, I  added the &lt;code&gt;homepage&lt;/code&gt; property in &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  ...
  "homepage": "deborah-digges.github.io",
  ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added another script &lt;code&gt;deploy&lt;/code&gt; to my &lt;code&gt;package.json&lt;/code&gt; which does a &lt;code&gt;build&lt;/code&gt; and then pushes the &lt;code&gt;public&lt;/code&gt; folder to the &lt;code&gt;gh-pages&lt;/code&gt; branch of my repository on Github.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "build": "gatsby build",
  "deploy": "npm run build &amp;amp;&amp;amp; gh-pages -d public",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila! I was able to deploy my site manually from my computer using the &lt;code&gt;npm run deploy&lt;/code&gt; script. My site was then up and running at &lt;a href="http://deborah-digges.github.io/"&gt;deborah-digges.github.io&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨Continuously✨ Deploying with Travis CI
&lt;/h2&gt;

&lt;p&gt;Great! I deployed my Gatsby site! However, I wouldn't want to be deploying a site manually from my laptop on a Friday afternoon.&lt;/p&gt;

&lt;p&gt;I decided to &lt;a href="https://www.atlassian.com/continuous-delivery/principles/continuous-integration-vs-delivery-vs-deployment"&gt;continously deploy&lt;/a&gt; my site so that every new commit would automatically be deployed to my GitHub Pages site. This was exciting, but I had bypassed an important step which is having automated tests for my site to ensure that a bad commit did not bring down my entire blog. However, I decided to live &lt;em&gt;dangerously&lt;/em&gt; and keep the testing of my Gatsby site for a future blog post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signing Up
&lt;/h3&gt;

&lt;p&gt;I signed up on the &lt;a href="https://travis-ci.org/"&gt;Travis CI&lt;/a&gt; website with my GitHub account and consented to sharing my GitHub data with Travis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enabling the Repository
&lt;/h3&gt;

&lt;p&gt;I then headed to the &lt;a href="https://travis-ci.org/account/repositories"&gt;repositories&lt;/a&gt; page and enabled builds for the &lt;code&gt;deborah-digges.github.io&lt;/code&gt; repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NrlCo8uq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qxnahg2cpjczoa1fbz00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NrlCo8uq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qxnahg2cpjczoa1fbz00.png" alt="Travis Toggle" width="880" height="79"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the travis.yml file
&lt;/h3&gt;

&lt;p&gt;I added a &lt;code&gt;travis.yml&lt;/code&gt; file to the root of my repository to tell Travis what to do on every commit to &lt;code&gt;master&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;language: node_js
before_script:
  - npm install -g gatsby-cli
node_js:
  - "10"
script: git config --global user.email $GH_EMAIL 2&amp;gt; /dev/null &amp;amp;&amp;amp;
  git config --global user.name $GH_USERNAME 2&amp;gt; /dev/null &amp;amp;&amp;amp;
  git remote set-url origin "https://${GH_USERNAME}:${GH_TOKEN}@github.com/deborah-digges/deborah-digges.github.io.git" 2&amp;gt; /dev/null &amp;amp;&amp;amp;
  yarn install &amp;amp;&amp;amp; yarn run deploy 2&amp;gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;script&lt;/code&gt; runs the &lt;code&gt;yarn run deploy&lt;/code&gt; step that I previously used to deploy my site locally. It is doing some extra steps to give Travis CI the right access to push to my GitHub repository.&lt;/p&gt;

&lt;p&gt;It tells the &lt;code&gt;git&lt;/code&gt; client installed on Travis CI who I am.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global user.name $GH_USERNAME
git config --global user.email $GH_EMAIL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To provide the script push access to my GitHub repository, I embedded my &lt;a href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token"&gt;Github Token&lt;/a&gt; environment variable in the remote URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote set-url origin "https://${GH_USERNAME}:${GH_TOKEN}@github.com/deborah-digges/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where did these environment variables come from?&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Travis Environment Variables
&lt;/h3&gt;

&lt;p&gt;I headed to my repository settings and made the following environment variables available to my script.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--trMQzf5N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0honf0v7zksioox8e385.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--trMQzf5N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0honf0v7zksioox8e385.png" alt="Travis Env Variables" width="880" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It took me a few attempts to get this right, but I am proud to say that my site is now being continously deployed to GitHub Pages on every commit to the &lt;code&gt;master&lt;/code&gt; branch of my repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GLmQprfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n2pu1tvhp0snzg9qyi7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GLmQprfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/n2pu1tvhp0snzg9qyi7a.png" alt="Travis Failed Attempts" width="880" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was a lot of work, and in my quest to search for a simpler solution, I will explore using a GitHub Action to continously deploy my site. Stay tuned for more dangerous living!&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>javascript</category>
      <category>devops</category>
      <category>github</category>
    </item>
    <item>
      <title>From Jekyll to Gatsby: 7 Simple Steps</title>
      <dc:creator>Deborah D</dc:creator>
      <pubDate>Thu, 17 Sep 2020 03:03:01 +0000</pubDate>
      <link>https://dev.to/deborahd/from-jekyll-to-gatsby-7-simple-steps-3an5</link>
      <guid>https://dev.to/deborahd/from-jekyll-to-gatsby-7-simple-steps-3an5</guid>
      <description>&lt;p&gt;Six years ago, during my final year in college, I was enrolled in a course on Open Source technology. To pass the course was to do two things: contribute to an open source project, and blog about it. Laughably, the only thing that propelled me to start writing publicly was the fear of failing the class.&lt;/p&gt;

&lt;p&gt;I passed the course and managed to get some semblance of a blog together. However, I didn't put too much effort into building the site itself since much of my effort was expended in writing the content and trying to creep my way into open source. At the time, Jekyll was all the rage and I went with a themed Jekyll starter called &lt;a href="https://github.com/poole/lanyon" rel="noopener noreferrer"&gt;Lanyon&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It served me well over the years, but my unfamiliarity with how it worked kept me from making any substantial changes to the structure of the site. I've finally taken the stand to move to a stack I'm more comfortable with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Gatsby?
&lt;/h2&gt;

&lt;p&gt;I considered refurbishing my blog with &lt;a href="https://www.gatsbyjs.com/blog/2017-11-08-migrate-from-jekyll-to-gatsby/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; and &lt;a href="https://dev.to/joserfelix/how-to-make-a-static-blog-with-next-js-2bd6"&gt;Next&lt;/a&gt;. I decided to go with Gatsby since it is a little more specialized towards static site generation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Get Migrating
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Scaffolding
&lt;/h3&gt;

&lt;p&gt;Getting a Gatsby project up and running is &lt;a href="https://www.gatsbyjs.com/docs/quick-start/" rel="noopener noreferrer"&gt;well-documented&lt;/a&gt; on the Gatsby site. Enhancing the project to generate a page from a markdown file is also &lt;a href="https://www.gatsbyjs.com/docs/adding-markdown-pages/" rel="noopener noreferrer"&gt;clearly explained&lt;/a&gt;.&lt;br&gt;
These are the steps I followed to get the initial project set up for the blog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used the &lt;code&gt;gatsby-source-filesystem&lt;/code&gt; plugin to read markdown files into Gatsby. I added an entry to the &lt;code&gt;plugins&lt;/code&gt; key in &lt;code&gt;gatsby.config.js&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: [{
   resolve: `gatsby-source-filesystem`,
   options: {
    name: `markdown-pages`,
    path: `${__dirname}/src/markdown-pages`
  }
}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Parsed markdown files using the &lt;code&gt;gatsby-transformer-remark&lt;/code&gt; plugin which extracted the frontmatter as data and the content as HTML.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: [
  {
    resolve: `gatsby-source-filesystem`,
    options: {
      name: `markdown-pages`,
      path: `${__dirname}/src/markdown-pages`
    },
  },
  `gatsby-transformer-remark`
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Created a &lt;a href="https://github.com/Deborah-Digges/gatsby-site/blob/master/src/templates/blogTemplate.js" rel="noopener noreferrer"&gt;template&lt;/a&gt; for blog posts using React to render a blog post's data as a React component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generated pages for all markdown files using the &lt;a href="https://github.com/Deborah-Digges/gatsby-site/blob/master/gatsby-node.js#L55" rel="noopener noreferrer"&gt;&lt;code&gt;createPage&lt;/code&gt; Gatsby API&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Created an &lt;a href="https://github.com/Deborah-Digges/gatsby-site/blob/master/src/pages/index.js" rel="noopener noreferrer"&gt;index page&lt;/a&gt; for all blog articles that displayed a list of links.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Migrating Content
&lt;/h3&gt;

&lt;p&gt;I copied all the markdown files from my old website to the folder indicated in the &lt;code&gt;gatsby-source-filesystem&lt;/code&gt; config entry: &lt;code&gt;markdown-pages&lt;/code&gt;. I was now able to see all my old blogs being listed on the index page, but most of the posts themselves looked terribly broken.&lt;/p&gt;
&lt;h3&gt;
  
  
  Fixing All the Things
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Links
&lt;/h4&gt;

&lt;p&gt;To avoid breaking links, I used the same slug format that my old Jekyll site used: &lt;code&gt;YYYY/MM/DD/Title&lt;/code&gt;. In my case, the slug was derived from the filename instead of the frontmatter, which required a little special handling.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To access the filename, I used &lt;a href="https://github.com/Deborah-Digges/gatsby-site/blob/master/gatsby-node.js#L8" rel="noopener noreferrer"&gt;createFilePath&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I extracted the slug and the date from the filename and passed them along as node fields, available to subsequent page queries.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const result = extractMetadataFromFilename(filePath);
date = result.date;
slug = result.slug;
createNodeField({ node, name: `date`, value: date });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Highlighting
&lt;/h4&gt;

&lt;p&gt;In my old Jekyll site, I was using &lt;code&gt;pygments&lt;/code&gt; for syntax highlighting of code snippets, which used syntax like this to create a highlight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{% highlight C++ %}
{% raw %}
  void f(int x, int n)
  {
    Gadget * g = new Gadget{n}; // Look ! I’m a Java Programmer :)
    if(x &amp;lt; 100) throw std::runtime_error{"weird"}; //leak
    if(x &amp;lt; 200) return; //leak
    delete p;
  }
{% endraw %}
{% endhighlight %}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since this no longer worked in Gatsby, I changed all highlights to be enclosed in three back-quotes which translates to a &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; tag enclosing a &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt; blog.&lt;/p&gt;

&lt;p&gt;I would like to eventually embed gists directly into my posts, but that's an improvement for a later blog post.&lt;/p&gt;

&lt;h4&gt;
  
  
  Images
&lt;/h4&gt;

&lt;p&gt;First, I copied over the images from my old site to &lt;code&gt;src/images&lt;/code&gt;. To make Gatsby aware of where my images were located, I added another plugin entry for the &lt;code&gt;gatsby-source-filesystem&lt;/code&gt; plugin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  resolve: `gatsby-source-filesystem`,
  options: {
    name: `images`,
    path: `${__dirname}/src/images`,
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I then modified the plugin entry for &lt;code&gt;gatsby-trasformer-remark&lt;/code&gt; to add the &lt;code&gt;gatsby-remark-images&lt;/code&gt; plugin to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  resolve: `gatsby-transformer-remark`,
  options: {
    plugins: [
      {
        resolve: `gatsby-remark-images`,
        options: {
          maxWidth: 800,
        },
      },
    ],
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this configuration, I was able to embed images inline using the familiar markdown format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![Architecture](../images/NN.jpg)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's important to use a relative path to the &lt;code&gt;images&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- src
  - markdown-pages
  - images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the directory structure above, &lt;code&gt;../images/image.png&lt;/code&gt; would be the path to an image referenced in a markdown file.&lt;/p&gt;

&lt;h4&gt;
  
  
  Gifs
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;gatsby-remark-images&lt;/code&gt; cannot handle gifs. I added the &lt;code&gt;gatsby-remark-copy-linked-files&lt;/code&gt; plugin to properly handle any gifs that gatsby encountered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  resolve: `gatsby-transformer-remark`,
  options: {
    plugins: [
      {
        resolve: `gatsby-remark-images`,
        options: {
          maxWidth: 800,
        },
      },
      `gatsby-remark-copy-linked-files`
    ],
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Favicon
&lt;/h4&gt;

&lt;p&gt;Again, I invoked the mighty plugin system of Gatsby and added another plugin entry in &lt;code&gt;gatsby-config.js&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  resolve: `gatsby-plugin-favicon`,
  options: {
    logo: `./src/favicon.ico`
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;

&lt;p&gt;I lazily copied over the &lt;a href="https://github.com/Deborah-Digges/gatsby-site/tree/master/src/styles" rel="noopener noreferrer"&gt;poole/lanyon theme&lt;/a&gt; to avoid me having to write any CSS. Let's not kid ourselves, I don't really know how to design a site.&lt;/p&gt;

&lt;p&gt;Since these are global CSS styles, I needed to import them into the &lt;code&gt;gatsby-browser.config.js&lt;/code&gt; file to make them apply to the generated HTML files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './src/styles/poole.css';
import './src/styles/lanyon.css';
import './src/styles/Calendas_Plus.otf';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Deploying
&lt;/h3&gt;

&lt;p&gt;To test the site out and compare it with my old site, I &lt;a href="https://epic-mirzakhani-8e39a6.netlify.app/" rel="noopener noreferrer"&gt;deployed&lt;/a&gt; the site to &lt;a href="https://www.netlify/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;. It was about as simple as going to the Netlify site, authorizing access to my GitHub repo, and providing a build command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxbdj9509t21923tozkrq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxbdj9509t21923tozkrq.png" alt="Build Command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing that No Links are Broken
&lt;/h3&gt;

&lt;p&gt;With my site deployed to Netlify, I tested that no links would be broken by ensuring that each link on the old site also existed on the new site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;links.forEach(link =&amp;gt; {
  link = link.replace('deborah-digges.github.io', 'epic-mirzakhani-8e39a6.netlify.app');
  request(link, (err, res, body) =&amp;gt; {
    if (err) { console.log('Page fetch failed', err); }
    console.log(link, res.statusCode);
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran the following script on each of the two pages of my old blog to extract all the links:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let links = document.querySelectorAll('a');
let siteLinks = []
for (let i=0; i &amp;lt; links.length; i++) {
  let linkText = links[i].textContent;
  linkText = linkText.replace(/\s+/g, ' ').trim();
  const link = links[i].href;
  siteLinks.push([linkText, link]);
}

for(let i=0; i &amp;lt; siteLinks.length; i++) {
  console.log(siteLinks[i][1]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Admittedly, it's a little rudimentary, but hey! it did the job.&lt;/p&gt;

&lt;h3&gt;
  
  
  Switching over
&lt;/h3&gt;

&lt;p&gt;Once I was ready to bid adieu to the shackles of my Jekyll site, I overwrote my Github User Pages &lt;a href="https://github.com/Deborah-Digges/deborah-digges.github.io" rel="noopener noreferrer"&gt;repository&lt;/a&gt; with the shiny new Gatsby site. I will be going over the details of deploying a Gatsby site to GitHub Pages in a subsequent blog post!&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Up
&lt;/h2&gt;

&lt;p&gt;Now that I'm using a system I understand a little better, I want to soon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement pagination&lt;/li&gt;
&lt;li&gt;Create categories for pages and allow browsing the blog by category&lt;/li&gt;
&lt;li&gt;Create a navigation element called &lt;code&gt;Content&lt;/code&gt; in the header which expands to &lt;code&gt;Blogs&lt;/code&gt;, &lt;code&gt;Drawings&lt;/code&gt;, &lt;code&gt;Book Reviews&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;Reading List&lt;/code&gt; navigation element&lt;/li&gt;
&lt;li&gt;Lean enough about CSS and design to create a better landing page (Maybe hire a designer?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd like to check it out in more detail, you can find the source code &lt;a href="https://github.com/Deborah-Digges/gatsby-site" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Tune in again for more exciting updates to my Gatsby blog!&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>jekyll</category>
      <category>migration</category>
      <category>blog</category>
    </item>
  </channel>
</rss>
