How to remove parent categories slug from subcategory URLs to make it shorter?

Just found that all the categories of and are in short style, without parent root. How to achieve this result then?

We can configure it by URL Rewrites

Go to Magento 2 Admin -> Marketing -> SEO & Search -> URL Rewrites

Find the path by searching Request path column.

Remove the cache php bin/magento cache:clean.

Refresh the front-end, click the main menu category then you can see the configured path.

Example i have modified.

Request path men/tops-men/tees-men.htm

Modified path tees-men.htm


You Can Build category URL path by

Modify getUrlPath($category) by Magento Plug-in feature.