From 07e4a2dafe248280b5610f8c7d09b0f30b530f54 Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Mon, 10 Jun 2024 09:41:25 -0400 Subject: Initial modifications to rebuilt only changed files based on mod date, performance updates --- build/posts/jekyll-sourcehut/index.html | 114 ++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 build/posts/jekyll-sourcehut/index.html (limited to 'build/posts/jekyll-sourcehut') diff --git a/build/posts/jekyll-sourcehut/index.html b/build/posts/jekyll-sourcehut/index.html new file mode 100644 index 0000000..2b41a53 --- /dev/null +++ b/build/posts/jekyll-sourcehut/index.html @@ -0,0 +1,114 @@ + + + + + + + + Hosting a Jekyll Site on Sourcehut + + + + + + + +
+

Hosting a Jekyll Site on Sourcehut

+

2021-12-06

+

I recently decided to switch my personal, static site’s hosting from Netlify to sourcehut pages. The process went fairly smoothly with only a couple minor hiccups; nothing rage-inducing. After everything was up and running smoothly, I figured writing out a step-by-step tutorial might help others who are thinking of doing a similar switch (or looking to host their first static site).

+

But first, let me briefly explain why I made the switch in the first place…

+

Why sourcehut pages?

+

Using Netlify as your static host is simple, intuitive and comes packed with a great deal of extra functionality you can easily add-on. So, why would I decide to switch over to sourcehut? The best answer comes directly off the main homepage of sourcehut.org:

+ +

After realizing all that, it’s pretty difficult to stick with Netlify’s proprietary stack…

+

Free but not “free”

+

I should note that using sourcehut pages does require you to be a contributing (read: paying) member on the platform. I’m a cheapo and selected the $2/month option but you might be inclined to donate more. Paying this “fee” is perfectly fine for me, considering the hosting quality (speed and storage) it affords me. It also doesn’t hurt that I get the “feel good vibes” of supporting an important, open source product.

+

Keeping that in mind, let’s get into setting up our static site!

+

Setting up your repo locally

+
    +
  1. Create a new account on sourcehut (or log in to an existing one)
  2. +
  3. Setup your billing to contribute monthly (tier amount is up to you)
  4. +
  5. Create a new repo under the git section1
  6. +
  7. Connect this repo locally (as you would via any other git host)
  8. +
  9. In this new local directory, place all your Jekyll files as you would with any other static hosting provider
  10. +
+

The sourcehut build file

+

In order to have your Jekyll site build and push the correct files live, you will need to use sourcehut’s build system. This will run every time you push out a new change to your repo (new blog post, page content changes, styling updates).

+

To make things easier, you can copy the build file below (remember to use your own information for usernames, git repo naming etc):

+
image: debian/stable
+oauth: pages.sr.ht/PAGES:RW
+packages:
+- ruby-full
+- ruby-dev
+environment:
+site: yourusername.srht.site
+sources:
+- https://git.sr.ht/~yourusername/your-repo-name
+tasks:
+- install-bundler: |
+    sudo gem install bundler
+- build: |
+    cd your-repo-name
+    bundle install
+    bundle exec jekyll build
+- package: |
+    cd your-repo-name/_site
+    tar -cvz . > ../../site.tar.gz
+- upload: |
+    acurl -f https://pages.sr.ht/publish/$site -Fcontent=@site.tar.gz
+
+

Save this file as .build.yml and place it in the root directory of your Jekyll source code.

+

Then, you just need to push your changes to the repo. If everything was setup properly, you’ll be able to see your live site at https://yourusername.srht.site (just give it a little bit of time to run the full build process)

+

Custom Domains

+

If you’re like me and want to use your own custom domain - have no fear! This process is actually quite easy.

+

First, add a new A Record through your domain provider:

+
@ IN A 173.195.146.139
+
+

Then change the following environment parameter inside your existing .build.yml file:

+
environment:
+site: yourcustomdomain.com
+
+

And that’s it - custom domain set! If you run into any issues check out the official documentation on custom domains.

+

Wrapping Up

+

Hopefully this helps to streamline the process for others to host their static sites through sourcehut. Having open and healthy competition among host providers and git workflows is essential to avoiding vendor lock-in.

+

Even low-effort support for open-source products (like where you host your static site or FOSS projects) can go a long way. Just some food for thought.

+
+
+
    + +
  1. +

    Thanks to McSinyx for pointing out that the repo used for creating your website can be named anything (instead of defaulting to your sourcehut username) 

    +
  2. + +
+
+ \ No newline at end of file -- cgit v1.2.3-54-g00ecf