When to use esc_url, esc_html, esc_attr, and friends?

Discovered esc_url today while customizing an _s theme. I understand what the function does (sanitizes the URL inside), but what I’m unsure of is the scope of its use.

It makes sense to me that if I’m accepting a URL input from a user, that I’d use this. But when I was looking at a function that displayed the entry’s meta info (see it here…line 129 at the moment), it used esc_url, which doesn’t make sense to me.

If I’m working on a theme, do I need to be escaping ANY URL that I put in my template files?

Solutions Collecting From Web of "When to use esc_url, esc_html, esc_attr, and friends?"