moved template related stuff from HomepageController to TemplateController