How do I create a link? Say I am extending The blockBase class to create a custom block, and I am implementing the blockBuild method to create some markup for my block. Something like this:

 class YourModuleBlock extends BlockBase {

   /**
     * Implements \Drupal\block\BlockBase::blockBuild().
     */
     public function build() {
      return array(
        '#markup' =&gt; 'This is a block!',
      );
     }
   }


If I wanted to provide a link in this markup, in D7 I would have used the l function, but this is no longer available (see here). So, I need to make available the new D8 method for generating links. I could just use an &lt;a&gt; tag, but this was never best practice in D7.

So, what is the right method to use for creating links and how do I make it available to my function?
\Drupal::l is deprecated.
Maybe this case will be useful for somebody

  use Drupal\Core\Url;
  use Drupal\Core\Link;
  $url = Url::fromRoute('entity.node.edit_form', array('node' =&gt; NID));
  $project_link = Link::fromTextAndUrl(t('Open Project'), $url);
  $project_link = $project_link-&gt;toRenderable();
  // If you need some attributes.
  $project_link['#attributes'] = array('class' =&gt; array('button', 'button-action', 'button--primary', 'button--small'));
  print render($project_link);