Render link elements in blocks? I'm trying to create a simple block that have some link fields. those links have some predefined values and after get any new values from the admin replace with values and then render that values to the theme:
my_module\src\Plugin\Block\MyBlock.php:

&lt;?php

namespace Drupal\my_modules\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;


/**
 * @Block(
 *   id = "my_block",
 *   admin_label = @Translation("My Block"),
 *   category = @Translation("My Block")
 * )
 */
class MyBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    // set default link field value.
    return array(
      'default_LinkA_url' =&gt; ('http://www.LinkA.com/'),
      'default_LinkB_url' =&gt; ('http://www.LinkB.com/'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    // Add a form field to the existing block configuration form.

  $form['block_LinkA_url'] = array(
    '#type' =&gt; 'url',
    '#title' =&gt; t('Link A:'),
    '#size' =&gt; 60,
    '#default_value' =&gt; $this-&gt;configuration['default_LinkA_url'],
  );
  $form['block_LinkB_url'] = array(
    '#type' =&gt; 'url',
    '#title' =&gt; t('Link B:'),
    '#size' =&gt; 60,
    '#default_value' =&gt; $this-&gt;configuration['default_LinkB_url'],
  );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    // Save our custom settings when the form is submitted.
    $this-&gt;configuration['default_LinkA_url'] = $form_state-&gt;getValue('block_LinkA_url');
    $this-&gt;configuration['default_LinkB_url'] = $form_state-&gt;getValue('block_LinkB_url');
  }

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#markup' =&gt; $this-&gt;configuration['default_LinkA_url'],
      '#markup' =&gt; $this-&gt;configuration['default_LinkB_url'],
    ];
  }
}


Whatsoever I try I can't get any result, and this code only show one link like below:
http://www.LinkA.com (a plain text only)

but what I want to achieve is some think like This:
Link A
This Link has Some CSS Style and Open in new page rater than being a plain text like above link.
I would be happy to hear what the problem is.
You have to build a render array like this:

   public function build() {
     $build = [];
     $build['linkA'] = [
       '#type' =&gt; 'link',
       '#title' =&gt; 'Link A',
       '#attributes' =&gt; [
         'class' =&gt; 'link-class',
         'target' =&gt; '_blank',
       ],
       '#url' =&gt; Url::fromUri($this-&gt;configuration['default_LinkA_url']),
     ];
     $build['linkB'] = [
       // ...
     ];

     return $build;
   }


You can add attributes to the link, classes for css or a target to open it in a new tab.