I have a problem where I look at software and want to add onion service support to it because they have a lot of useful properties including making self hosting from residential easier, and just generally being a good tool for making some software more p2p capable. And making distributed and p2p software is another life long interest of mine.

To that end, I’ve been hosting this site, made with Jekyll on an onion service as well as danballard.com for a while now and wanted to “add onion service support to Jekyll” (along with a long list of other software…). What does that mean for Jekyll tho, a static site generator?

Well the conclusion I came to is that I might like to have some content on the onion service version of the site only. I can even envision a potential future where the open web site gets paired down to a landing page directing folks to the onion service where all the content becomes hosted.

How did I enable this? Well I wrote a small patch for Jekyll that adds a new optional config option to the site _config.yml called target. It is set to “default” by default. The same option has been added to frontmatter for content, and defaults to matching the site’s value. What this means is that by default, the site generates the same. If you want specific content for a specific site, add target: onion to that content, and create a second site config, like `_config_onion.yml’:

url: http://danbal6a2lkho4arcx2dpa6ykg6fyvukeoqowjlgs3uzmt6wrz4s54id.onion
destination: _site_onion
target: onion

and then generate a second site (which will appear in the configured _site_onion) with:

bundle exec jekyll build --config "_config.yml,_config_onion.yml"

Jekyll configs stack and override previous versions.

I’ve done just this, you can see that the new page onion-test.html is only available on the onion service version of this site, generated from the same codebase:

You can also adjust content inside the page using Jekyll templating now:


{% if site.target == "default" %}
Site target: Default
{% elsif site.target == "onion" %}
Site target: Onion
{% endif %}

Demo:

Site target: Default

You Can Too (The Code)

Having done this work, I obviously want to share it, so I’ve created a PR with the Jekyll project but I’m not actually sure it is something they will want to adopt and accept.

So if you’d like it now, I’m hosting it in a post 4.4.1 branch and also as a patch file you can apply, as I have, to a checked out 4.4.1 branch on my server

Then in your site’s Gemfile change:

gem "jekyll", "~> 4.4"

to

gem "jekyll",  :path => '~/src/jekyll'

adjusting the path to where ever you have checked out the jekyll repo and applied the patch. You’ll need to do this locally and on your server if you build on it rather than rsync to it.