SEO URL removing IDs and .html

I am starting to test the new SEO URL functionality implemented in PR #2446 but I’m running into a couple of concerns.

I noticed in config.js#15 that .html is hard-coded to be appended to the URL. I thought this was going to be an optional feature managed through the config.

I also see in product.js#249 that the item.slug is being generated by concatenating the name and ID. Why isn’t it using the url-key from Magento here? I thought that was one of the purposes behind this SEO URL PR.

Am I missing where these things are configured somewhere? Or are these not features that were included in this update?

Hey @rain2o:

  1. config.js is meant to be editable - this is why this url_path setting algorithm was put in there. Please feel free to adjust it to your needs.

  2. after urlDispatcher introduced in 1.9 - the slug field is no longer being used for URLs. The ids were added because the url_key was not guaranteed to be unique (it was unique across the category level as far as i remember)

Let me know how it works after these tips :slight_smile:

Thanks @pkarw. I feel like I’m still missing something.

  1. That makes sense that config.js is meant to be editable. However, since we are use mage2vs as a node_module within vsf-api, this file isn’t exactly something we can edit. Is there a way to modify this configuration while using it as part of the vsf-api environment?
  2. I do see that urlDispatcher uses url_path now instead, however when looking into mage2vs I see that it creates the url_path value on products by using the slug or _slugify( + '-' + if slug isn’t set. This is in config.js::productUrlPathMapper(). I suppose this means since it is in config.js it can be modified to our needs (assuming my question above has a solution), but if I modify the logic to create product.url_path will the routing handle it accordingly?

I also noticed that product.url_path is using the first category’s url_path to create the first part of the url. The problem is it is using Default Category, which in its nature (within Magento context) doesn’t have a url_key because it isn’t intended to be a viewable category. It’s more of a container in which to house the categories your store has. Because it doesn’t have a url_key, the mage2vs script generates one for it, using the old format of name + id. And this is getting included in the product.url_path. Is there a way to tell it to disregard default category?

Good one with the first point! To be honest I’ve no answer to that. I mean: if you need to modify config.js it would be probably easier to just run magento2vuestorefront installed outside the vsapi.

With the second one: yes it should. Put anything you like into url_path and VS should be able to just use it for generating and then routing urls it’s 100% dynamic

Default Category - yeah, it seems you found the next edge case that needed to be supported. Please feel free to propose a change in regards of skipping this category. It might be distinguished from the others by checking the level (==1 for root)

i did changes as @rain2o said in start after url changed. i go to product url same as what i want but if refresh the page or copy url and paste another tab application gone 404 or page error.