Refactor page templating