<?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: Hugo GEORGET</title>
    <description>The latest articles on DEV Community by Hugo GEORGET (@hugogeorget).</description>
    <link>https://dev.to/hugogeorget</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%2F96803%2Ff8c35725-edfe-4563-be15-46be34cdcc9b.png</url>
      <title>DEV Community: Hugo GEORGET</title>
      <link>https://dev.to/hugogeorget</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hugogeorget"/>
    <language>en</language>
    <item>
      <title>Deploy a GatsbyJS blog on GitHub Pages</title>
      <dc:creator>Hugo GEORGET</dc:creator>
      <pubDate>Fri, 08 Nov 2019 13:24:50 +0000</pubDate>
      <link>https://dev.to/hugogeorget/deploy-a-gatsbyjs-blog-on-github-pages-5cb6</link>
      <guid>https://dev.to/hugogeorget/deploy-a-gatsbyjs-blog-on-github-pages-5cb6</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally written for &lt;a href="https://hugogeorget.github.io/blog/first-blog-post-how-to/"&gt;my blog&lt;/a&gt;. This can explain the way this post is written. The technical point still stand on its own though.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hi there !&lt;/p&gt;

&lt;p&gt;What better way to start my blog than by explaning how it works ?&lt;/p&gt;

&lt;p&gt;This blog was built using the &lt;a href="https://github.com/gatsbyjs/gatsby-starter-blog"&gt;gatsby-starter-blog&lt;/a&gt; starter.&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.gatsbyjs.org/"&gt;&lt;strong&gt;GatsbyJS&lt;/strong&gt;&lt;/a&gt; is a static site generator using the &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; JavaScript framework. This framework allows us to easily deploy our site to various platforms, such as &lt;a href="https://www.netlify.com/"&gt;Netlify&lt;/a&gt; or in our case &lt;a href="https://pages.github.com/"&gt;&lt;strong&gt;GitHub Pages&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The following Github Pages configuration will allow you to deploy your own blog in a path (&lt;em&gt;username&lt;/em&gt;.github.io/&lt;em&gt;reponame&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;This setup allows you to deploy your own blog for &lt;strong&gt;free&lt;/strong&gt;, how cool is that ?&lt;/p&gt;
&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;If you want to do the same thing as I did, here is what you need :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A version of &lt;a href="https://nodejs.org/en/"&gt;Node JS&lt;/a&gt;&amp;gt;=8.11.3&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://www.gatsbyjs.org/tutorial/part-zero/#using-the-gatsby-cli"&gt;Gatsby CLI&lt;/a&gt;. Follow the link for instructions on how to install&lt;/li&gt;
&lt;li&gt;A free &lt;a href="https://github.com/"&gt;GitHub&lt;/a&gt; account&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Local installation
&lt;/h2&gt;

&lt;p&gt;Gatsby provides different starters that will help you start developing your site.&lt;br&gt;&lt;br&gt;
You can even submit your own starters to be featured in the &lt;a href="https://www.gatsbyjs.org/starters/"&gt;Starter Library&lt;/a&gt; !&lt;/p&gt;

&lt;p&gt;To create a new local repository containing the Gatsby Starter Blog, use the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gatsby new blog https://github.com/gatsbyjs/gatsby-starter-blog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will create and put the project files in the &lt;code&gt;blog&lt;/code&gt; folder, as well as run the &lt;code&gt;npm install&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;After that, execute the following commands and start coding !&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;blog
gatsby develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;If you need more information on Gatsby starters, here is a &lt;a href="https://www.gatsbyjs.org/docs/starters/"&gt;link&lt;/a&gt; to the Gatsby documentation on the subject.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;This tutorial only covers the deployment of the site.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  GitHub Pages setup
&lt;/h2&gt;

&lt;p&gt;To deploy your local Gatsby site to GitHub Pages, you will need to add the &lt;code&gt;gh-pages&lt;/code&gt; package to your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i gh-pages &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additionally, you will need to specify the deployment folder in which your site will be in &lt;code&gt;gatsby-config.js&lt;/code&gt;.&lt;br&gt;
For our example (&lt;em&gt;username&lt;/em&gt;.github.io/&lt;em&gt;reponame&lt;/em&gt;), add a path prefix as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;pathPrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/reponame&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, add the following script to your &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 json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deploy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"gatsby build --prefix-paths &amp;amp;&amp;amp; gh-pages -d public"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run the &lt;code&gt;npm run deploy&lt;/code&gt; command to build your site and deploy the content of the &lt;code&gt;public&lt;/code&gt; folder to your &lt;code&gt;gh-pages&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If this tutorial doesn't suit your GitHub Pages deployment case, more information is available in the &lt;a href="https://www.gatsbyjs.org/docs/how-gatsby-works-with-github-pages/"&gt;Gatsby documentation&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's it ! Your site should be available to the desired path !&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>react</category>
      <category>github</category>
    </item>
  </channel>
</rss>
