spf13/hugo — pull request #252 by tummychow (2014-04-08 15:25:49+00:00)
Title: Fix permalinks to subdomains

Alright, so I know I opened issue #230 a while ago, decided to just bite the bullet and PR a fix.

To review, the issue was that, if a site is hosted at a subdomain, eg `tummychow.github.io/myproject`, you can't use custom permalinks, because the permalinks have to begin with a slash. The slash indicates a URL starting from the root domain, so Go's URL resolution library sees the slash and discards any subdomains. Therefore, if you have a baseurl of `yoursite.com/yoursubdomain`, and your permalinks are `/:title`, then permalinks will be resolved to `yoursite.com/:title` instead of `yoursite.com/yoursubdomain/:title`.

The fix for this is pretty simple, I just took out the check in permalinks.go that requires the leading slash. If you specify permalinks without a leading slash, then they'll be relative to the baseurl including subdomains, which resolves the issue. I also corrected any tests that were broken by the change. Let me know what you think.