I'm writing a workaround to fix the breaking changes introduced to our XML feed when we updated from Drupal 8.4 to 8.5. Since PATH is no longer available but has been replaced with LINK, I've had to craft the Rewrite Results to be /news/{{ view_node }}, which displays a properly formatted URL in the preview:


However, in the actual XML feed, it comes out like this:


arbitrarily adding an underscore and breaking the URL. Is there a way to make this not happen?

  • +1 for having created the issue on drupal.org (link).
    – leymannx
    Jul 25, 2018 at 12:35

1 Answer 1


After much work I came up with a workaround. My first thought was to add a Twig filter to views-view-row-rss.html.twig like so <link>{{ link | replace('_', '') }}</link> but the underscore was still being displayed, which told me that either 1. the Twig filter wasn't working or 2. the underscore was being applied later in the render process.

The Twig template's documenation made reference to a template_preprocess_views_view_row_rss() hook I found implemented in /core/modules/views/views.theme.inc so I added the following hook to my custom.theme PHP file:

function ncei_preprocess_views_view_row_rss(&$variables) {
  $item = $variables['row'];
   $variables['title'] = $item->title;

   //$variables['link'] = $item->link;
   $variables['link'] = str_replace("_", "", $item->link);

   if (isset($item->description) && is_array($item->description)) {
     $variables['description'] = (string) \Drupal::service('renderer')-            

 $variables['item_elements'] = [];
 foreach ($item->elements as $element) {
   if (isset($element['attributes']) && is_array($element['attributes'])) {
     $element['attributes'] = new Attribute($element['attributes']);
   $variables['item_elements'][] = $element;

I commented out the original line above for reference, but I'm setting the link variable to the item's link, stripped of all undertscores. This isn't the best solution, and will break if the link actually contains underscores, but it worked as a temporary workaround in the meantime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.