Refactor static-pages code with erb optimization