Moved link logic to template tag