Refactor the common layout template.