Drupal 8 Add the current title to the breadcrumb

As you may have seen from my other posts I am currently migrating a theme from Drupal 7 to Drupal 8. Drupal 8 now includes a much better breadcrumb system that by default traverses down the path of the current page.

Warning: There is a high probability this content is outdated or incomplete and is left here purely for archival purposes

If you want to add the current page to the breadcrumb then include this code in your .theme file replacing MYTHEME with the name of your theme

function MYTHEME_preprocess_breadcrumb(&$variables){
       if(($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']){
               $variables['breadcrumb'][] = array(
                         'text' => $node->getTitle(),
                         'url' => $node->URL()
                       );
       }
}