If you’re used to working with The Loop, then you’re all too familiar with the_permalink. Simply put, it’s how to get the link to the post currently being rendered in the browser.
But if you’re working on anything more advanced than using the typical Loop, then you may be looking to get the permalink for a post by other means – perhaps by a page slug or by a page’s title.
I’ve had to do this in some recent work, as well, so here’s what I do when I need to get permalink by slug: