I'm working on a Shopify app at the moment, and I want to be able to fetch and store articles from blogs. However, the Shopify 'Article' API doesn't return a specific URL for each of the article entries, and I'm wondering if there's a better way than the following format:
http://{shopUrl}.com/blogs/{blogName}/{articleId}-{articleTitle}
where {articleTitle} is an encoded, URL-friendly version of the article's title.
Also, just out of curiosity, why doesn't Shopify return URLs for fetched items like products, articles, et cetera? Is this for flexibility's sake?
There is one trick to make your life easier - you don't need to slug the article title, you can just do this (editing your example):
http://{shopUrl}/blogs/{blogName}/{articleId}
The articles title is appended to the url in order to provide a more readable url, as well as for SEO purposes. But it's not necessary if you just want to construct the url.
As for why Shopify doesn't provide urls for resources in the API, it's because a resource such as a product may have more than one url - it could be a part of a collection and accessed through the collection, or accessed through /products/{{handle}}, etc... So you want to construct your own url based on the context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With