Abstract new_post and new_page into newFile to avoid code duplication