How to regenerate Magento 2 url keys for products in bulk
Setting up your Magento store for search engines, you are supposed to consider many aspects, and product URL key optimization is among them. Magento 2 URL key is a part of product URL that is in fact an address of a product page on your site. Making URLs relevant and unique is the first step to getting higher priority in search engine result page.
By default Magento generates URL keys based on product name. Although your product name may include some stop words, that does not conform SEO standards or you just need to update Magento 2 URL keys for products across store views.
To rewrite URL keys for multiple products, you can resort to usual product editing or make use of Store Manager import facility and bulk update keys in one go.
URL Key VS URL Path
Before regenerating keys for your Magento 2 products, consider that URL key and URL path are different notions. Url_key is the part of static URL that describes a product or a category. It is filled in Magento as is. If there is not value provided, Magento takes the name of the product, lowercasing it and replacing blanks with hyphens. Url_path is created from URL key and product URL suffix specified in Stores->Settings->Configuration->Search Engine Optimization.
Updating URL Keys Through Import
In order to regenerate Magento URL keys in the process of import, you should of course include them in the import file. If you need to update URL keys only, then it will be enough to have product identifier (SKU or ID) and product URL key itself in the feed. There is no need to input URL path, since it will be created automatically as it has been already outlined. Sample file we use for import includes columns for product identification and URL keys.
Further the file should be uploaded to your store via the import profile. In order to update URL keys successfully make sure you have configured the settings as we outline below.
- Having several languages enabled on your store, you will get them displayed on Select Store View to Import Products to step. If you need to regenerate Magento 2 URL keys for a specific store view, then you need to disable [Default Values] Store View checkbox above and select specific store view respectively.
- Further you have to link fields of your import file to corresponding ones within Magento database and select a suitable identifier. In our case it's Product ID:
- The last step requires you to designate import options. Magento 2 URL key update will be performed if you configure the settings as following:
- Import Method - select Modify Only import method, since you renew existing products
- Delete 'url_key' for existing products - enable this option to remove current URL keys for imported products and substitute them with those, you have in CSV file
- Reindex product data - make sure data reindex is enabled
ImportantProduct ID is used for update only, so it can be used of you need to regenerate Magento 2 URL keys for existing products. In case of creating new products, you should use SKU and have it in the file.
Product URLs play an important role in evaluating how well your site is indexed by search engines. Make your store SEO friendly setting up relevant product URLs with Store Manager. Regenerate URL keys in the most approachable way for numerous entities.
Regenerate URL Keys for Products Through Import Try Now
Magento 2 SEO: Bulk Add/Update Meta Details
Check detailed guides updating Magento meta details or creating unique ones and get a sample of the import file. Read More...
Detect Magento Data Integrity Issues
Learn how to use Store Diagnostics tool to detect problems related to product attributes automatically. Read More...
Multi Source Inventory in Magento 2
Tutorial on how track inventory on multiple Magento product sources (MSI). Read More...
Magento 2 SEO Features
The ultimate guide on Magento 2 SEO optimization (XML map generation, meta tags optimization, etc...) Read More...
If you mean the functionality of Store Manager, yes it's also possible to update URL keys with the Multi Editor tool a proper SQL expression.