DEV Community

Cover image for Deploy your Publish website for free on GitHub Pages
Arnaud Joubay
Arnaud Joubay

Posted on β€’ Originally published at paraside.in on

1 1

Deploy your Publish website for free on GitHub Pages

πŸ™ Create a new GitHub repository

First things first, let's create a repository to host your website content.

We'll call it mywebsite , which means it will be accessible at https://yourusername.github.io/mywebsite.

Instead of mywebsite, if you use [yourusername.github.io](http://yourusername.github.io) it will be accessible at https://yourusername.github.io. See https://pages.github.com for more infos about that.

/images/4/Screenshot<em>2020-08-11</em>at_15.21.16.png

🎞 Setup the Publish pipeline

Open your main.swift file and add deployedUsing: .gitHub("yourusername/mywebsite") to your publish pipeline, which should look something like this:


try MyWebsite().publish(
     withTheme: .casperish,
     deployedUsing: .gitHub("sowenjub/mywebsite"),
     additionalSteps: [
         .installPlugin(.readingTime()),
         .installPlugin(.pygments()),
     ],
     plugins: [.pygments()]
 )

Enter fullscreen mode Exit fullscreen mode

Now run your site in Xcode (Product > Run command or ⌘+R), then open your terminal and run


publish deploy

Enter fullscreen mode Exit fullscreen mode

Head over to your repository, refresh and make sure your files are there.

πŸ₯ Setup GitHub Pages

Open your repository settings, scroll down to the GitHub Pages section and select the master branch. Don't forget to click the Save button.

/images/4/Screenshot<em>2020-08-11</em>at_15.28.14.png

Once you're done, it should give your the address to your website.

/images/4/Screenshot<em>2020-08-11</em>at_15.29.07.png

And you're done! Unless you want to use a custom domain name, which can be set in the same settings panel.

πŸ’ Bonus: Deploying from Xcode

Instead of deploy using the command line with publish deploy, you can deploy straight from Xcode.

First, create a New Scheme, we'll call it Deploy MyWebsite. Click on it to reopen the same menu and select "Edit Scheme…".

/images/4/Screenshot<em>2020-08-11</em>at_22.21.08.png

Select Run and in the Arguments Passed On Lauch, add --deploy without space.

/images/4/Screenshot<em>2020-08-11</em>at_22.24.05.png

Now anytime your Run your website with the scheme (Product > Run command or ⌘+R), it will deploy your site to GitHub.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (1)

Collapse
 
ameysunu profile image
Amey Sunu β€’

If you have a PRO account from your organization or as a Github educational account, you can get a free domain from name.com for a year and host your Github Page site on your new name.com domain.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay