Build HTML templates recursively