daggerhartlab / lark
Drupal module for exporting and importing content.
Requires
- php: >=8.3
- drupal/core: ^11.3 || ^12
- league/commonmark: ^2.6
Requires (Dev)
- drupal/config_pages: ^4.0
- drupal/entity_embed: ^1.8
- drupal/metatag: ^2.2
- drupal/paragraphs: ^1.23
- drupal/pathauto: ^1.16
- drush/drush: ^13
Suggests
- drupal/config_pages: Adds Lark's export and import tabs to config pages.
- drupal/entity_embed: Embedded entities in formatted text are exported as dependencies.
- drupal/metatag: Meta tags are exported and imported with their entities.
- drupal/paragraphs: Paragraphs are exported and imported with their parent entities.
- drupal/pathauto: Exports keep whether an alias is generated automatically.
Provides
None
Conflicts
None
Replaces
None
README
Lark provides the functionality to export and import content entities along with their dependencies from one Drupal site to another.
Requirements
- Drupal 11.3 or later, or Drupal 12
- PHP 8.3 or later
Setup
Visit the Lark Sources page (/admin/config/lark/source), and create a new Source for
where you will export your content. Ideally, this directory should be outside
the document root of the Drupal site.
You can make your exports directory relative to a module or theme by providing the module or theme name within brackets in the directory path.
Example: [my_custom_module]/content will be converted into
modules/custom/my_custom_module/content.
Visit the Lark settings page and set default Lark Source.
Exporting Entities
Entities can be exported from the entity's view/edit page by clicking the "Lark"
tab. This will provide a form where you can easily export the entity and its
dependencies. The export will be saved to the selected Lark Source, or can be
downloaded as a .tar.gz file.
To export an entity using drush, the following command can be used:
drush lark:export-entity <source id> <entity type> <entity id>
Embedded entities
Entities embedded in formatted text fields are exported as dependencies of the entity that embeds them:
- Media embeds:
<drupal-media data-entity-uuid="…"> - Entity Embed module embeds:
<drupal-entity data-entity-type="…" data-entity-uuid="…"> - Files uploaded through the editor:
<img data-entity-type="file" data-entity-uuid="…">
Embeds reference entities by UUID, so the text itself is not changed on export
or import. Editor-uploaded images also hard-code the file's URL in src, which
only stays valid when the importing site uses the same public files path and
the "asset import file exists" setting is Replace (the default).
Importing Entities
Exported entities can be imported using the Source's UI, located at
/admin/config/lark/source/<source id>. This page will list all exports available
within the source along with their export status.
If the entity already exists on the site, the entity can be re-imported by visiting the entity's edit page and clicking the "Lark" tab.
To import entities using drush, the following commands can be used:
# Import all entities from all Lark Sources. drush lark:import-all-entities # Import all entities within a given source. drush lark:import-source <source id> # Import a single entity and its dependencies from a specific Lark Source. drush lark:import-entity <source id> <uuid>
Links to other content
A link field or menu link that points to another entity (entity:node/5,
/node/5) is exported with that entity's UUID. The linked entity is not
exported with it: export it too if the importing site needs it.
On import, links are matched to the importing site's entities once every
entity of the run has been imported, so the order of the exports doesn't
matter. drush lark:import-all-entities also resolves links between sources.
A link whose target doesn't exist on the importing site is imported as plain
text (<nolink>), and a warning names the entity, the field and the missing
target. Import the entity holding the link again once the target exists, and
the link is restored.
Until then, the target is kept in the link's options. Saving the entity's edit form discards it, as Drupal's link widget doesn't keep link options. Importing the entity again still restores the link, but exporting it from that site after such an edit exports a link to nothing.
User Interface
/admin/config/lark/source- List of all sources. View a source to see its export contents./lark/export/node/{node}- Export a single node entity./lark/export/media/{media}- Export a single media entity.