rewrite template layout