Getting "Call to a member function getName() on null" in custom breadcrumb
You can also use hook_system_breadcrumb_alter to achieve this:
Try this:

/**
 * Implements hook_system_breadcrumb_alter().
 */
function MyModule_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &amp;$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) {
  $node = \Drupal::request()-&gt;attributes-&gt;get('node');
  if ($node &amp;&amp; $node instanceof Drupal\node\Entity\Node) {
    if ($node-&gt;bundle() == 'article') {
      // Add Articles item.
      $breadcrumb-&gt;addLink(Link::createFromRoute(t('Articles'), '&lt;none&gt;'));
      // Add category term item to breadcrumb.
      // Change here the field_tags with your taxonomy you want to add to breadcrumb.
      $term_id = $node-&gt;field_tags-&gt;getValue()[0]['target_id'];
      $term = Term::load($term_id);
      $breadcrumb-&gt;addLink(Link::createFromRoute($term-&gt;getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' =&gt; $term-&gt;id()]));
      // Add title as breadcrumb item.
      $request = \Drupal::request();
      $route_match = \Drupal::routeMatch();
      $page_title = \Drupal::service('title_resolver')
        -&gt;getTitle($request, $route_match-&gt;getRouteObject());
      if (!empty($page_title)) {
        $breadcrumb-&gt;addLink(Link::createFromRoute($page_title, '&lt;none&gt;'));
      }
    }
  }
}


Update: To fix the error.
Update the applies method to apply your breadcrumb only on articles as it mentioned in @Jdrupal answer:

  public function applies(RouteMatchInterface $route_match) {
    $parameters = $route_match-&gt;getParameters()-&gt;all();
    if (isset($parameters['node'])) {
      return $parameters['node']-&gt;getType() === 'article';
    }
    if (isset($parameters['term'])) {
      return TRUE;
    }
  }


The error comes from the line:

$term = $route_match-&gt;getParameter('taxonomy_term');


$term equal NULL its normal, you are in node page so the taxonomy_term param always null, so try to get your term from the node object something like:

 $node = \Drupal::request()-&gt;attributes-&gt;get('node');
 // Change the field_tags with your filed.
 $term_id = $node-&gt;field_tags-&gt;getValue()[0]['target_id'];
 $term = Term::load($term_id);