Problem/Motivation

For some reason, after migrating content into Drupal, HTML in the Body field is shown until the node is saved. Only then are the HTML tags used.

Steps to reproduce

Do a migration, and see that HTML tags in the Body field are not rendered, but escaped and output, until the node is saved, like this (i.e. the title and author field are formatted):

Facere quis amet temporibus aut molestias Add to Default shortcuts

By samantha.marvin , 14 March 2026

<p>Esse error voluptas. Voluptatem laborum illum reprehenderit. Eum laudantium cupiditate fugiat consequuntur. <a title="Alias in." href="http://www.example.com/autem-ut-quisquam-velit-qui">quis</a&gt; accusamus sed praesentium saepe Quia possimus laudantium sequi et nobis Blanditiis ducimus deleniti dolore commodi ratione. Rerum sint impedit facere omnis est At totam quam doloremque voluptatum recusandae Dolor sunt tenetur quia Voluptatem accusantium qui dignissimos veritatis. Repellat tempora impedit et. Impedit fuga et. sed qui vitae Soluta suscipit amet minus aut. Voluptatem minima et ad et. Eum cum et aut eligendi. Est quis dolorem nam incidunt. Molestias saepe placeat ad. Soluta hic consequatur labore dolore eum ipsa Qui rerum <a title="Neque error quia recusandae voluptatum." href="http://example.org/rerum-tenetur-ullam-eum-ea-voluptate-in">earum aut adipisci</a> A nostrum animi sapiente quam omnis.</p>
<ul><li>Rerum aut voluptas dolore officiis id et molestiae</li><li>Sint ut quisquam facilis quas</li></ul>

Proposed resolution

Have the HTML take effect immediately after a migration, and not require to save the node first.

There could be another issue for this, I just could not find it ... :)

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

ressa created an issue. See original summary.

ressa’s picture

Issue summary: View changes
longwave’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide some sample migration YAML that triggers this bug? I've done a number of node body migrations and never seen it.

longwave’s picture

ressa’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Thanks for a fast reply. Below is an example. It is created by the WordPress Migrate module, and the same thing happens in #3535554: HTML tags in body text is shown as plain text:

uuid: d692021e-0022-450a-87f0-3ff3a244edec
langcode: en
status: true
dependencies: {  }
id: my_wordpress_content_post
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - WordPress
migration_group: my_wp
label: 'Import content from WordPress XML'
source:
  plugin: url
  data_fetcher_plugin: file
  data_parser_plugin: xml
  urls: {  }
  item_selector: '/rss/channel/item[wp:post_type="post"]'
  fields:
    -
      name: title
      label: 'Content title'
      selector: title
    -
      name: post_id
      label: 'Unique content ID'
      selector: 'wp:post_id'
    -
      name: content
      label: 'Body of the content'
      selector: 'content:encoded'
    -
      name: excerpt
      label: 'Excerpt of the content'
      selector: 'excerpt:encoded'
    -
      name: pubDate
      label: 'Publish date of the content'
      selector: pubDate
    -
      name: post_date
      label: 'Post date of the content'
      selector: 'wp:post_date'
    -
      name: status
      label: 'Published status of the content'
      selector: 'wp:status'
    -
      name: creator
      label: 'Username of the content creator'
      selector: 'dc:creator'
    -
      name: post_tag
      label: 'Tags assigned to the content item'
      selector: 'category[@domain="post_tag"]/@nicename'
    -
      name: category
      label: 'Categories assigned to the content item'
      selector: 'category[@domain="category"]/@nicename'
    -
      name: thumbnail_id
      label: 'Thumbnail assigned to the content item (Featured image)'
      selector: "wp:postmeta[wp:meta_key='_thumbnail_id']/wp:meta_value"
    -
      name: link
      label: 'Persistent path'
      selector: link
  ids:
    post_id:
      type: integer
process:
  title:
    -
      plugin: skip_on_empty
      method: row
      source: title
      message: 'Cannot import empty titles. This may include trashed posts from the WordPress import file.'
  _content/value:
    -
      plugin: get
      source: content
  _content/summary:
    -
      plugin: get
      source: excerpt
  created:
    -
      plugin: callback
      source: post_date
      callable: strtotime
  changed:
    -
      plugin: get
      source: '@created'
  status:
    -
      plugin: static_map
      source: status
      default_value: 0
      map:
        publish: 1
  path/pathauto:
    -
      plugin: default_value
      default_value: 0
  path/alias:
    -
      plugin: str_replace
      source: link
      search: 'http://ddev-wp-web'
      replace: ''
    -
      plugin: str_replace
      search: /\/$/
      replace: ''
      regex: true
    -
      plugin: str_replace
      search: '/^(?=^\/\?)(.*)$/'
      replace: ''
      regex: true
  uid:
    plugin: migration_lookup
    migration: my_wordpress_authors
    source: creator
  body: '@_content'
  _content/format:
    plugin: default_value
    default_value: full_html
  type:
    plugin: default_value
    default_value: article
  field_tags:
    plugin: migration_lookup
    migration: my_wordpress_categories
    source: category
  field_image:
    plugin: migration_lookup
    migration: my_wordpress_attachments
    source: thumbnail_id
destination:
  plugin: 'entity:node'
idMap: {  }
migration_dependencies:
  required:
    - my_wordpress_tags
    - my_wordpress_categories
    - my_wordpress_attachments
include: null
hongpong’s picture

This may have been an issue in wordpress_migrate where our text formats are not correctly assigned to certain field structures. #3516531: Add body field picker w default to wizard & processing and #3516531: Add body field picker w default to wizard & processing. With Drupal 11 the field structure changed and we think there are some bugs in this area. ( I just put in a logger that should at least enforce the correct fields are only selected with current import config implementation). Any diagnostic help w finding that kind of problem will probably help us, watchdog logging if it changes etc.

ressa’s picture

Status: Active » Closed (works as designed)

Your assumptions were correct @hongpong, and thanks for fixing this in the related WordPress Migrate module issue. Closing this issue, since the Drupal core Migrate module works well.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.