Put permalink creation into function.