add templating and fix first page issue