If the url reflects the correct path, you can add this to your .theme file.
function hook_preprocess_breadcrumb(&$variables) {
$variables['breadcrumb'] = array();
$variables['node'] = \Drupal::routeMatch()->getParameter('node');
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
$variables['breadcrumb'][$key] = array('text' => $link->gettext(), 'url' => $link->getUrl()->toString());
}
// As of Drupal 8.1.3, core caches breadcrumb parent. This breaks what I'm trying to do. Good-bye to this caching rule.
$variables['#cache']['contexts'][] = 'url';
}
EDIT
If the url is missing the 'Main menu' part, you can manually set the breadcrumb for any specific content type. Again in the theme file.
function hook_preprocess_breadcrumb(&$variables) {
$variables['breadcrumb'] = array();
$variables['node'] = \Drupal::routeMatch()->getParameter('node');
$variables['type'] = \Drupal::routeMatch()->getParameter('node')->getType();
switch($variables['type']) {
case 'YOUR-CONTENT-TYPE':
$variables['breadcrumb'] = array(
array(
'text' => 'Home',
'url' => '/'
),
array(
'text' => 'Main menu',
'url' => 'Main menu url'
),
array(
'text' => $variables['node']->getTitle(),
'url' => $variables['node']->URL()
),
);
break;
default:
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
$variables['breadcrumb'][$key] = array('text' => $link->gettext(), 'url' => $link->getUrl()->toString());
}
break;
}
// As of Drupal 8.1.3, core caches breadcrumb parent. This breaks what I'm trying to do. Good-bye to this caching rule.
$variables['#cache']['contexts'][] = 'url';
}