Can't get custom block module to appear in “Place blocks” screen in Drupal 8


April 2019


290 time


I am trying to write a custom block module in drupal 8 that will allow me to place this block into my drupal pages using the block layout screen.

I'm very new to drupal - so this is very much a "hello world" project (initially) to figure out how this works. To this end, I have been following youtube video instructions as well as reading through whatever doco I can find on the net [and also a couple of books], but to no avail [yet].

What I have done, is created a directory "walker" in the modules folder in which I have created which looks like this:

name: Walker
description: A filewalker
core: 8.x
package: Custom
type: module

In the same directory I have created Walker.module which looks like this:

 * @file
 * Code for the walker module.

I have then created a directory:


and created a file called WalkerBlock.php with the following content:

 * @file
 * Code for the walker block.

namespace Drupal\walker\Plugin\Block;

use Drupal\Core\Block\BlockBase;

 * Provides a walker block
 * @Block(
 *   id = "walker",
 *   admin_label = @Translation("The walker block"),
 *   category = @Translation("Blocks")
 * )

class WalkerBlock extends BlockBase
    public function build()
        return array('#markup' => 'Walker block');

If I run the command "find . -type f | grep Walker" from my root Drupal directory, I get the following output:


Yet, though the documentation and videos I have read suggest that this should be all I require, the Walker block does not appear in the block layout screen as an option that I can place in one of the block regions.

Can anyone see what I'm doing wrong? I have been going around and around in circles for hours now.

Note also, that I have gone to the drupal8/admin/config/development/performance screen and clicked the "Clear all cache's" button

Thanks heaps for any assistance,

David Buddrige :-)

1 answers


Check the module where you defined you block plugin is installed or not. If the module is not installed, go to the extend page of your site search for your module name and enable it. If you are using drush then you can simply enable it by

drush en moduleName

After that, I think you will get the block name in place block of your block layout section.