Friday, September 11, 2009

Subdomains on Github

I've been using Github for a while, and it didn't really occur to me to write about it. It's just something that I assume everyone uses, but don't talk much about. Like toilet paper.

But I just discovered some two-ply goodness that I had to share. Github link juice; or more correctly - instant SEO credibility by owning a github subdomain. If you visit http://coderoshi.github.com, you'll be redirected to this site. But how?

There are two way of going about it. If you visit a subdomain that hasn't been used you'll get this page:
Try it: http://alice.github.com/

That's most of the trick. Create a new public repository (don't worry, it's free) of "yourusername.github.com" (don't forget the ".github.com part). Add an index.html file and push to master. Viola.

(for you non-git people, when you create the repository, github gives you clearer instructions than I could here)

But there's more. To do a simple redirect, just paste in some html with a meta refresh tag, or to keep the nice subdomain url to mask your GeoCities site (look it up, kids) - just upload a page with a blank iframe, which contains your site.
<html>
<style>body,html{padding:0px;margin:0px;}</style>
<body>
<iframe src="http://www.coderoshi.com" width="100%" height="100%"
style="border:0px" marginheight="0" marginwidth="0" frameborder="0">
<a href="http://www.coderoshi.com">Coderoshi - Death By Overcoding</a>
</iframe>
</body>

But there's more! If you don't want something so sloppy, and merely want a URL redirect to your site, instead of an index.html file, upload a file named CNAME, which contains your domain. Mine looks like this:
coderoshi.com
That's it! Instant credibility from google (you're a real subdomain of the very popular github.com domain).

No comments: