Render a custom menu in a custom block I want to create a block that contains somes links of a menu, without using the interface.
So I created a custom module. Inside, there are somes files.

a mymodule/test.links.menu.yml : 

test.menu.listown:
  title: list
  route_name: test.listown

test.menu.addnew:
  title: Add new
  route_name: test.addnew
  weight: 0
  parent: test.menu.listown


and a mymodule/src/Plugin/Block/test_block_main.php

class test_block_main extends BlockBase {
  public function build(){

    $mp = \Drupal::menuTree()-&gt;getCurrentRouteMenuTreeParameters("test.menu.listown");
    $test = \Drupal::menuTree()-&gt;load("test.menu.listown", $mp);
    $render = \Drupal::menuTree()-&gt;build($test);

    return array('#markup' =&gt; \Drupal::service('renderer')-&gt;render($render));
  }

}


I cleared caches (drush cache-rebuild). When I go to my homepage, the "test_block_main" is displayed, but it is empty. Why is my custom block empty? Is the "test.menu.listown" parameter passed to the methods not correct?
You also need to provide the actual menu config entity as default configuration in config/install. Note that test.menu.listown is not a valid menu name, they can't contain dots only alphanumeric characters and dashes.

I'd recommend to prefix all default configuration with your module name, so that they're unique. Something like mymodule-something.

And, try to follow coding standards and conventions. For example, always use camelCase for class names, like TestBlockMain in TestBlockMain.php.

And last, avoid calling render() yourself whenever possible. You can just return a render array from a block.