Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is it possible to add a page to a menu during migration? I have a very simple example here, which creates a few pages with the Migrate Plus module, but is it possible to also add them to a menu, like fx "Main navigation" (main
)? The order isn't super important: https://www.drupal.org/files/issues/migrate_plus.migration.default_pages...
Comments
Comment #2
mikeryanMoved to the core queue, not really anything to do with migrate_plus...
I'm not that conversant with menu migration, but I can tell you it's separate from node migration. See http://cgit.drupalcode.org/drupal/tree/core/modules/menu_link_content/mi... for how it's done in the Drupal-to-Drupal case.
Comment #3
ressa CreditAttribution: ressa as a volunteer commentedThanks for the tip @mikeryan. I had hoped it was just a matter of defining link name, menu name and perhaps weight. I'll have a look into the example page you linked to.
Comment #4
mikeryanComment #6
ressa CreditAttribution: ressa at Ardea commentedHere is an example of a simple menu migration I made, called migrate_plus.migration.menu_link_main.yml:
You can create the pages with the file migrate_plus.migration.default_pages.yml:
Comment #7
agerard CreditAttribution: agerard commentedI know this is old, but I'm curious about the last post (#6) - should that code actually work? I have a migration that successfully brings in taxonomy terms and creates content from a json export of fields (from non-Drupal content items). I'd like to also create the menu entries, like [/thisContentType/thisName] where thisContentType could be a string, yaml constant, or injected into the source json, which already contains thisName for each item. It's been difficult to find a general overview of how the menu migration process might work, and I am trying to figure out, by slowly-accreting knowledge from posts buried in various places, how to write yaml that could do this by using some combo of default_value or constant (for a sub-path) and pageID to create them directly thru a dependent migration yaml. I'm still not clear on which menu fields must even be populated. Based on this example (except that the source is json rather than internal), nothing I've tried works, and the various errors I've gotten aren't helpful.
I can also try using a script to create/specify menu links in the json before import, but as everything I've tried so far is just guesswork and I don't know where it's failing, I may end well up at the same dead end so I thought I'd ask...
Comment #8
quietone CreditAttribution: quietone as a volunteer commented@agerard, this issue is closed for three years. To get support I suggest opening a new Support Request issue or, alternatively, join the #migration channel in Drupal Slack. There are many folk there that can help.
Good luck!
Comment #9
dylan_plasterI am commenting here as it is one of the first (and only) relevant results I was able to find when searching for importing/migrating menus into Drupal from a non-Drupal source. I was unable to find any good information despite hours of researching. Here is the migration I was able to come up with which successfully migrated in both nodes AND menu links, while also rendering the active trail and menu display properly. An example of how to successfully migrate menu links into a drupal 9 site:
Create two csv files. the first one is for Node and has columns like so:
Nodes.csv:
TabID | TabName | TabPath | (any other columns you need like body content, etc)
Links.csv:
TabID | alias | TabName | parentId
Where parentID points to the parent of a menu link in a hierarchy, and the 'alias' column is the same as the TabPath column from the Nodes CSV.
Now that the CSVs are configured, this yml will import the menu links (after the nodes are imported first):
remember to replace the path with the path to your csv. Hopefully this saves someone hours of trial and error like me