Linking to GitHub repositories from my own site

Published on under the IndieWeb category.

A screenshot of the IndieWeb Search Github repository

After a discussion with Tantek in the IndieWeb chat [^1], I decided to do more work towards my “own your links” project. My first pass at this was to create /github/ and /instagram/ links on this domain that take you to my GitHub and Instagram pages, respectively. The idea is that I can refer people to my profiles by using a link that I own rather than pointing to the platform-first link. It’s a small difference but one that I care about.

We had a discussion about how to own all of one’s links to a platform, not just links to their home page. Imagine if I could link to a GitHub repository from my own site or a project issue. Tantek had achieved this with an apache redirect. I looked into the nginx equivalent and wrote a simple redirect rule that lets you do deeper redirects. Here’s an example link that points to my Micropub GitHub project repository:

https://jamesg.blog/github/micropub/

This link will redirect you to my Micropub GitHub project page. I can use this same pattern to point to other repositories and parts of repositories (i.e. issue pages or pull requests).

Here is the configuration rule I wrote to support this change:

location  ^/github/(.*) {
     return 307 https://github.com/capjamesg/$1;
}

This rule takes the text after any URL that begins with /github/ and adds it to the end of https://github.com/capjamesg/. This means I can redirect to any page on GitHub easily from my site without having to worry about maintaining a list of repositories, updating my redirects every time I make a new project, and all of the work that would come with such an approach. This nginx approach is simple, elegant, and functional.

The 307 redirect is used to make sure the redirect is seen as temporary, for the resource to which a redirect points may change further down the line (i.e. if I changed my username on a platform).

I have documented this on the IndieWeb own your links page where you can find more information describing the “own your links” idea and how you can implement it on your site.

From now on, I intend to link to my GitHub pages using the links the directive above supports.

[^1] If you are interested in personal websites and want to meet other people who share that interest, please do check out the IndieWeb discuss page on the wiki. That page has links you can use to join the chat on various platforms.

Also posted on IndieNews.

Go Back to the Top