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

Just found that all the categories of https://www.rxsafetyglassesusa.com/ and https://www.rxsafetyglassescanada.com/ 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

Or

You Can Build category URL path by

\vendor\magento\module-catalog-url-rewrite\Model\CategoryUrlPathGenerator.php
Modify getUrlPath($category) by Magento Plug-in feature.