fsck -vf /dev/hdc1 > log

## Rewrite

(This post is related to a static site generator script I use. Please see the forked repo. for the code, and my earlier post, Tinkering chisel for more.)

A couple of months ago, I noticed that GitHub, which serves my site, served my URLs even when I removed the .html part. (Ditto for feed urls ending with .xml too.) From a quick curl query, I realized it uses nginx. Given my love for clean URLs, I could not stop myself from taking advantage of this. So, I updated chisel to generate all posts ending with .html as usual, but modify URL generation (for permalinks) to exclude the .html part, since the server rewrite is enabled. For other internal links, I just removed the .html extension from templates pointing to pages such as the archive and the colophon.

Update: Since the change is at multiple places in the code, I’ve updated chisel with a couple of mutually exclusive options in settings, viz., URLEXT and PATHEXT, to make this simpler for a chisel user. (Instead of manually editing chisel at various places, the user can just set these two parameters within settings and be done with it.)

The default setting now — assuming server recognizes .html extension but does not require its inclusion when referring to a URL — is as follows:

URLEXT = ""
PATHEXT = ".html"


This above is what I use. (Note that you should not set both to empty or .html strings in the above; this would lead to unintended results.)

The fallback option is as follows:

URLEXT = ".html"
PATHEXT = ""


This above setting would be suitable if your server does not recognize .html files if they are referred to without .html extension in URLs.

Since I also run chisel on my home server, here’s what I had to do to enable rewrite:

I edited the default file, which serves our local family site, in the following folder on my home server:

cd /etc/nginx/sites-enabled


and added this following in it:

location / {
try_files $uri.html$uri/ =404;
}


I now have clean URLs.1 Awesome; and by the way, old URLs (posts ending with .html) work too.

Update [Feb 23]: On my home server, the entire copy of this site is served from the url ckunte.dev, instead of the usual localhost. To set this up, first I edited the file, /etc/nginx/sites-available/default and updated in the server section with the following:

server_name ckunte.dev;


I tested nginx setup by running sudo nginx -t, which looked good when I saw the following:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful


Next, I reloaded the saved nginx settings by running sudo nginx -s reload.

Then, I edited the /etc/hosts file to append the following:

127.0.0.1 localhost ckunte.dev


Now, to reload the above update, I did run the following:

sudo /etc/init.d/networking restart


Now, the complete replica of my site (ckunte.net) looks and works exactly in its local repository (as ckunte.dev). I use it to test everything — post drafts, site design, etc., until I am happy with it before pushing it to my github repository to be served on the web.

1. This can also be set up in the file, /etc/nginx/nginx.conf, should you prefer the setting be global.