Deploy your Publish website for free on GitHub Pages - DEV
<div data-article-id="426514" id="article-body" readability="106.0448392555"> <p>First things first, let's create a repository to host your website content.</p> <p>We'll call it <code>mywebsite</code> , which means it will be accessible at <code>https://yourusername.github.io/mywebsite</code>.</p> <p>Instead of <code>mywebsite</code>, if you use <code>yourusername.github.io</code> it will be accessible at <code>https://yourusername.github.io</code>. See <a href="https://pages.github.com" style="color: inherit; text-decoration: none;" name="readabilityLink-1">https://pages.github.com</a><a href="#readabilityFootnoteLink-1" class="readability-DoNotFootnote" style="color: inherit;"><small><sup>[1]</sup></small></a> for more infos about that.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7goQyr2i--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.21.16.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7goQyr2i--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.21.16.png" alt="/images/4/Screenshot<em>2020-08-11</em>at15.21.16.png" loading="lazy"/></a></p> <p>Open your <code>main.swift</code> file and add <code>deployedUsing: .gitHub("yourusername/mywebsite")</code> to your publish pipeline, which should look something like this:<br/></p> <div class="highlight" readability="14"><pre class="highlight plaintext"><code> try MyWebsite().publish( withTheme: .casperish, deployedUsing: .gitHub("sowenjub/mywebsite"), additionalSteps: [ .installPlugin(.readingTime()), .installPlugin(.pygments()), ], plugins: [.pygments()] ) </code></pre></div> <p>Now run your site in Xcode (Product > Run command or ⌘+R), then open your terminal and run<br/></p> <p>Head over to your repository, refresh and make sure your files are there.</p> <p>Open your repository settings, scroll down to the GitHub Pages section and select the master branch. Don't forget to click the Save button.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z772rGI5--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.28.14.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z772rGI5--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.28.14.png" alt="/images/4/Screenshot<em>2020-08-11</em>at15.28.14.png" loading="lazy"/></a></p> <p>Once you're done, it should give your the address to your website.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YSzC5Fg2--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.29.07.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YSzC5Fg2--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at15.29.07.png" alt="/images/4/Screenshot<em>2020-08-11</em>at15.29.07.png" loading="lazy"/></a></p> <p>And you're done! Unless you want to use a custom domain name, which can be set in the same settings panel.</p> <p>Instead of deploy using the command line with <code>publish deploy</code>, you can deploy straight from Xcode.</p> <p>First, create a New Scheme, we'll call it <code>Deploy MyWebsite</code>. Click on it to reopen the same menu and select "Edit Scheme…".</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nKCaENPr--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at22.21.08.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nKCaENPr--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at22.21.08.png" alt="/images/4/Screenshot<em>2020-08-11</em>at22.21.08.png" loading="lazy"/></a></p> <p>Select Run and in the Arguments Passed On Lauch, add <code>--deploy</code> without space.</p> <p><a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nkhSLcvp--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at22.24.05.png" class="article-body-image-wrapper"><img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nkhSLcvp--/climit%2Cfauto%2Cflprogressive%2Cqauto%2Cw880/https://paraside.in/images/4/Screenshot2020-08-11at22.24.05.png" alt="/images/4/Screenshot<em>2020-08-11</em>at_22.24.05.png" loading="lazy"/></a></p> <p>Now anytime your Run your website with the scheme (Product > Run command or ⌘+R), it will deploy your site to GitHub.</p> </div><div id="readability-footnotes"><h3>References</h3><ol id="readability-footnotes-list"><li><small><sup><a href="#readabilityLink-1" title="Jump to Link in Article">^</a></sup></small> <a href="https://pages.github.com" name="readabilityFootnoteLink-1">https://pages.github.com</a><small> (pages.github.com)</small></li></ol></div>
