How do I get a link to a WP page within a loop?

So, it turns out that if you pass a Post or Page object to the_permalink() or get_page_link() it will override the post object set by the loop whereas passing an ID won’t.

In the previous example you would use <?php echo get_page_link($mypage); ?> instead.

Source of get_page_link() had the answers: