Fixes root path logic for templates.