How can I programmatically get various common user profile related URLs? I'd like to get the following URLs in Drupal 8:

/user/register
/user/login
/logout
/user

I already know I can use \Drupal::service('path.current')-&gt;getPath() to get the current path. I want to build links to redirect users.
How do I get these paths programatically?
The user URLs (or routes to be more &quot;Drupal correct&quot;) are defined by the core user module (core/modules/user/user.routing.yml)
E.g.
user.register:
  path: '/user/register'
  ...

user.login:
  path: '/user/login'
  ...

user.logout:
  path: '/user/logout'
  ...

user.page:
  path: '/user'
  ...

So you can programmatically build links to these routes like so:
&lt;?php

use Drupal\Core\Link;

// Replace user.login with other routes such as user.page
$user_login_link = Link::createFromRoute(
  t('User log in link'), // The link text
  'user.login', // The link URL generated from the route
);