Creating a block programmatically in a theme on Drupal 8? So I was hoping to have my theme create special blocks for different parts of the front page so that they can be moved around easily later. I added the files to mytheme/src/Plugin/Block/BlockName.php but they never show up anywhere on the site or the block manager even after clearing cache.

Here's the code for one of my blocks (MediaPanel.php):

&lt;?php
/**
 * @file
 * Contains \Drupal\mytheme\Plugin\Block\MediaPanel.
 */

namespace Drupal\mytheme\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides my custom block.
 *
 * @Block(
 *   id = "media_panel",
 *   admin_label = @Translation("Media Panel"),
 *   category = @Translation("Blocks")
 * )
 */
class MediaPanel extends BlockBase {

/**
   * {@inheritdoc}
   */
  public function build() {
    return array('#markup' =&gt; 'hello world');
  }
}

?&gt;


Do I have to use a module for creating Blocks? It would be inconvenient to have to make a module to create blocks that will be specific to my theme anyway.
Yes. Themes can't provide plugins.