Console Commands
Navigation includes console commands you can run from your Craft project’s directory.
Import & Export
These commands export a menu to a portable JSON file and import it again, such as to copy a menu between environments. JSON Import and Export explains what the file contains and how imports behave.
Lists every menu with its ID, handle and name, then the JSON files in the export folder. The export folder is storage/navigation-exports unless you pass another folder as the argument.
php craft navigation/import-export/list
php craft navigation/import-export/list ./menu-exportsExports a menu, with all of its nodes, to a JSON file. Pass the menu’s handle as the argument or with --handle.
| Option | Description | Default |
|---|---|---|
--handle | The handle of the menu to export, when it isn’t passed as the argument. | |
--path | The file to write the export to. | storage/navigation-exports/navigation-[handle].json |
php craft navigation/import-export/export-json mainMenu
php craft navigation/import-export/export-json mainMenu --path=./mainMenu.jsonImports a menu from a JSON file. Pass the file’s path as the argument or with --path. A path that doesn’t exist is also looked for in the export folder, so a file name from list is enough. By default the import creates a new menu, and gives it a new handle when the file’s handle is already taken.
| Option | Description | Default |
|---|---|---|
--path | The JSON file to import, when it isn’t passed as the argument. | |
--update | Updates the existing menu with the same handle instead of creating a new one, replacing its whole node tree. The import fails when no menu has that handle. | false |
--create | Creates a new menu, which is already the default. | false |
php craft navigation/import-export/import-json ./mainMenu.json
php craft navigation/import-export/import-json navigation-mainMenu.json --updateMigrating From Other Plugins
These commands copy menus from another navigation plugin into Navigation. The other plugin’s tables must still be in the database, and the commands leave its data in place. Each command reports what it created, skipped and couldn’t copy. The migration guides explain what each plugin’s menus become.
Every migration command takes the same options.
| Option | Description | Default |
|---|---|---|
--handle | A comma-separated list of the other plugin’s menu handles to migrate. Leave it out to migrate every menu. | |
--skip-existing | Skips a menu whose handle is already used by a Navigation menu. Without it, the migrated menu is saved with a new handle. | false |
Migrates menus from FreeNav.
php craft navigation/migrate/free-nav
php craft navigation/migrate/free-nav --handle=mainMenu,footerMenu
php craft navigation/migrate/free-nav --skip-existingMigrates menus from the Menu plugin.
php craft navigation/migrate/menuMigrates menus from Menu Builder.
php craft navigation/migrate/menu-builderMigrates menus from Navigate.
php craft navigation/migrate/navigateMigrates menus from Navkit.
php craft navigation/migrate/navkitMigrates menus from Olivemenus.
php craft navigation/migrate/olivemenusMigrates menus from TKA Navigation.
php craft navigation/migrate/tka-navigationResaving Nodes
Resaves Navigation nodes through Craft’s resave command, such as after changing a menu’s field layout. It also takes Craft’s usual resave options, such as --queue and --site.
| Option | Description | Default |
|---|---|---|
--menuId | A comma-separated list of menu IDs whose nodes to resave. Leave it out to resave nodes in every menu. |
php craft resave/navigation-nodes --menuId=1
php craft resave/navigation-nodes --menuId=1,2 --queueRepairs
Repairs menus that have no site settings saved. It restores the sites from project config, from the menu’s element records or, on a single-site install, the primary site. A multi-site menu it can’t work out is skipped and reported.
php craft navigation/menus/fix-sitesRepairs a database where menu elements took over the IDs of other elements. It restores the affected elements, moves the colliding menus to their own elements, recreates missing menu elements and restores empty titles on linked entry nodes. Only sites the upgrade guide describes need it.
php craft navigation/menus/fix-menu-element-collisions