fixed link generation and directory scans for templates