{"componentChunkName":"component---src-templates-blog-post-js","path":"/this-blog/","result":{"data":{"site":{"siteMetadata":{"title":"Hi, Blog","author":"Yoni Schirris"}},"markdownRemark":{"id":"e1ac64bb-1346-5d7a-8d28-6b5188c47a8d","excerpt":"In this short post I would like to share how I set up this blog, possibly for you to learn or get an idea about how to set up a blog yourself.  The Website The…","html":"<p>In this short post I would like to share how I set up this blog, possibly for you to learn or get an idea about how to set up a blog yourself. </p>\n<h3>The Website</h3>\n<p>The website has been set up with <a href=\"https://www.gatsbyjs.org/\">Gatsby</a>, a JS framework built on top of <a href=\"https://reactjs.org/\">ReactJS</a> to make building a blazing-fast static website easier than ever. I used the <a href=\"https://github.com/gatsbyjs/gatsby-starter-blog\">Gatsby Starter Blog</a> to quickly get something up and running. I like it because it’s lightweight, I can write my blog posts without logging in anywhere, as I can write them using Markdown in my <a href=\"https://typora.io/\">recently discovered sexy markdown editor</a>. Also, it gets me to see and work with React, which is one of the bigger frontend frameworks out there nowadays.</p>\n<p>If you also want to set up your own blog with this stack, then let’s get started! If you start entirely from scratch, you can run the following commands in your terminal to install everything that’s required:</p>\n<p>Let’s first install <a href=\"https://brew.sh/\">HomeBrew</a>, a lovely package manager allowing you to install everything from your terminal (on MacOS)</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">/usr/bin/ruby -e <span class=\"token string\">\"<span class=\"token variable\"><span class=\"token variable\">$(</span><span class=\"token function\">curl</span> -fsSL\n https://raw.githubusercontent.com/Homebrew/install/master/install<span class=\"token variable\">)</span></span>\"</span></code></pre></div>\n<p>Run </p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">brew -v</code></pre></div>\n<p>to see if it has been installed, correctly. It should return something like </p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">Homebrew <span class=\"token number\">2.1</span>.13\nHomebrew/homebrew-core <span class=\"token punctuation\">(</span>git revision 791eb<span class=\"token punctuation\">;</span> last commit <span class=\"token number\">2019</span>-10-13<span class=\"token punctuation\">)</span>\nHomebrew/homebrew-cask <span class=\"token punctuation\">(</span>git revision 7f1286c<span class=\"token punctuation\">;</span> last commit <span class=\"token number\">2019</span>-10-13<span class=\"token punctuation\">)</span></code></pre></div>\n<p>With Brew, we can then install <a href=\"https://nodejs.org/en/\">NodeJS</a>, which allows Javascript to be run on your machine, which is used to compile / build your code. This is a requirement for the Gatsby Command Line Interface (or CLI):</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">brew <span class=\"token function\">install</span> node</code></pre></div>\n<p>and you can check if it’s indeed installed correctly by running</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">node -v</code></pre></div>\n<p>Gatsby requires Node 8 or higher.</p>\n<p>Additionally, it installs the <a href=\"https://www.npmjs.com/\">Node Package Manager (NPM)</a>, which is used to install Node Libraries.</p>\n<p>I also recommend installing Node Version Manager (NVM), which allows you to switch between Node versions. This can be helpful if you rquire a specific version of Node for a project</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">brew <span class=\"token function\">install</span> nvm</code></pre></div>\n<p>If for some reason you have an older version of Node running currently, you can change this using e.g.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">nvm use <span class=\"token number\">8</span></code></pre></div>\n<p>to run Node 8.</p>\n<p>With this, we can then install the Gatsby CLI:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> -g gatsby-cli</code></pre></div>\n<p>with which we can create our website:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">gatsby new my-blog-starter https://github.com/gatsbyjs/gatsby-starter-blog\t</code></pre></div>\n<p>You can then go into the directory, and see it on your local host:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token builtin class-name\">cd</span> my-blog-starter/\ngatsby develop</code></pre></div>\n<p>If you now go into your browser and navigate to <code class=\"language-text\">https://localhost:8000</code> you will see your blog!</p>\n<p>If you want to better understand how to work with Gatsby, check their in-depth from-scratch <a href=\"https://www.gatsbyjs.org/tutorial/\">tutorial</a>. </p>\n<p>You will probably want to put this in a <a href=\"https://github.com/\">Github</a> repository, as many hosting services can pull it directly from your github repo!</p>\n<h3>Hosting</h3>\n<p>As I worked a bit with Amazon Web Service (AWS) services over the past 1.5 year, I thought it would be fun to set this up myself, too, and was extremely surprised with how easy this was. The domain it’s currently on was a birthday present from my previous employees, and I also thought it would be cool to experiment with how DNS/CNAME changes work to let this domain serve the content on some AWS service.</p>\n<p>As I navigated to the <a href=\"https://aws.amazon.com/\">AWS website</a>, one of their services, called <a href=\"https://aws.amazon.com/amplify/\">AWS Amplify</a> seemed to do exactly what I needed: Static app deployment and hosting in ~5 minutes: great! (Apparently there was a <a href=\"https://www.gatsbyjs.org/docs/deploying-to-aws-amplify/\">Gatsby tutorial</a> about this, too, although they recommend <a href=\"https://www.netlify.com/\">Netlify</a> )</p>\n<span class=\"gatsby-resp-image-wrapper\" style=\"position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 390px;\">\n      <a class=\"gatsby-resp-image-link\" href=\"/static/a350378c1feebc61607e6777d74fe188/14f69/aws-amplify.png\" style=\"display: block\" target=\"_blank\" rel=\"noopener\">\n    <span class=\"gatsby-resp-image-background-image\" style=\"padding-bottom: 92.3076923076923%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAABYlAAAWJQFJUiTwAAACI0lEQVQ4y6VUa2/SUBjm1/rdGD/p5odd4genWbxOk4XNuYii6MguER0LCAwQBnPcBttYhXEppVzbDdo+Ht6tsyxGS3aS0/ec9j3PeZ73UoumabjuMGJYBo+dUhuxcgdZQQLXOIUg9ZBvyMjUJAQLLeTqMnvXJ+vjmqh0zlBqn+FQlMF3e0OgBOjM1DDt5TDh4WBP8viY4rEQr+De1jHubuaxtFuB66BO+3H3Ma0fbRdww5mFPcETkKKq54DqNSQrf5FODEORONZdW/CHIuB+FeH2+OFye5FMZxGOxtn3GGK7CQRCUfiCP5A7zONnIo29RAo78T3ySWdyfyQ3Gk2UK1WIzHYlidZ1sQGhLqLK12h/lOcgCHW6UCR/HpVqDYViCSelMq0JcECz2Wqh31fQ7UoE2Ov1yCqKMnK2CTB3cMTk7SMYjjJZEXh820y2D6kLGSoL+CDW2n/mpeSrt6gXGTOWg9l6tRgdrx4aFWwIUK8jbyCM2TkraiwhutyRGBoPtTtd3BqbxtTDZ1hZ/3oJZIyRKYY64PzSe0zNPMXEgyeYsy4jkdofYm8G1KI7J1lGH79cwKtFG9lJBvzu0ypk+XSIqSnJfVZvH5wbWHzrIFbL9hVi+nz+DUKsC4ilopqP4Rpru89rLtgcq3htc+DmnUkCvD1+H7MvrCielM8TZJZhkPXyF9a7ftargyy73N9pbnoDcG58Q0EHVLXR6tDsT/Rf4zeIVFC4BiTTaAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;\"></span>\n  <img class=\"gatsby-resp-image-image\" alt=\"This image\" title=\"This image\" src=\"/static/a350378c1feebc61607e6777d74fe188/14f69/aws-amplify.png\" srcset=\"/static/a350378c1feebc61607e6777d74fe188/cf440/aws-amplify.png 148w,\n/static/a350378c1feebc61607e6777d74fe188/d2d38/aws-amplify.png 295w,\n/static/a350378c1feebc61607e6777d74fe188/14f69/aws-amplify.png 390w\" sizes=\"(max-width: 390px) 100vw, 390px\" loading=\"lazy\">\n  </a>\n    </span>\n<p>When you go to the <a href=\"https://us-east-2.console.aws.amazon.com/amplify/home?region=us-east-2#/create\">amplify console</a> everything is quite straightforward and they give you a step-by-step guide to follow.  I did adjust the build script, though, to the following:</p>\n<div class=\"gatsby-highlight\" data-language=\"yml\"><pre class=\"language-yml\"><code class=\"language-yml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token number\">0.1</span>\n<span class=\"token key atrule\">frontend</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">phases</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">build</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">commands</span><span class=\"token punctuation\">:</span> \n        <span class=\"token punctuation\">-</span> cd my<span class=\"token punctuation\">-</span>blog<span class=\"token punctuation\">-</span>starter <span class=\"token comment\"># Go into directory</span>\n        <span class=\"token punctuation\">-</span> npm install  <span class=\"token comment\"># install all node modules</span>\n        <span class=\"token punctuation\">-</span> gatsby build  <span class=\"token comment\"># build all into public dir</span>\n  <span class=\"token key atrule\">artifacts</span><span class=\"token punctuation\">:</span>\n  \t<span class=\"token comment\"># Tell AWS that I want to host the public directory</span>\n    <span class=\"token key atrule\">baseDirectory</span><span class=\"token punctuation\">:</span> /my<span class=\"token punctuation\">-</span>blog<span class=\"token punctuation\">-</span>starter/public/\t\n    <span class=\"token key atrule\">files</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> <span class=\"token string\">'**/*'</span> <span class=\"token comment\"># and all files in it\t\t\t\t\t\t\t</span>\n  <span class=\"token key atrule\">cache</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">paths</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span></code></pre></div>\n<p>Whenever it was accessible on an Amplify Domain (<code class=\"language-text\">https://master.dq1ww2mlbpel9.amplifyapp.com</code>) I set up the link to a custom domain by following <a href=\"https://docs.aws.amazon.com/amplify/latest/userguide/custom-domains.html\">their doc</a>. I would personally recommend to set up a domain name in AWS Route 53, as that is perfectly compatible.</p>\n<p>If you’ve managed to read all of it until here, awesome! Here’s a cookie 🍪</p>\n<p>If you have any questions or need any help setting up your own blog post, let me know my sending a DM <a href=\"https://twitter.com/Yoni_Sch\">via Twitter</a>. Also let me know if you liked this post, learned something from it, or have ideas for improving it (being my blog set-up, or this specific blog post!).</p>","frontmatter":{"title":"This blog's set-up","date":"October 26, 2019","description":"This blog has been built with Gatsby, and is hosted using AWS Amplify"}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"/this-blog/","previous":{"fields":{"slug":"/hello-world/"},"frontmatter":{"title":"Hello World"}},"next":{"fields":{"slug":"/getting-started-with-ai/"},"frontmatter":{"title":"Getting started in the field of Artificial Intelligence"}}}}}