Fix static rendering pagination

This fixes the problem where if you're using static rendering and
you're on the second page, the prev link is wrong. It points to
(for example) index_page1.html, but that should be index.html.
This fixes that and also cleans up a bunch of the code.

Fixes #13