-
Notifications
You must be signed in to change notification settings - Fork 12
Description
As a user (content creator)
I want to have a slug (easy to read and relevant) URL for the content I am publishing
So that any person seeing the URL can immediately infer/deduce the content.
A :slug is user/SEO friendly path to an item of content.
Instead of using the :cid of the content e.g: gVSTedHFGBetxyYib9 or a UUID e.g: f587be12-bdd4-4723-a8db-e0ee2384aea0 which is useless from a both a user's and SEO perspective.
Good summary: https://yoast.com/slug/ + https://www.wpbeginner.com/glossary/post-slug/
Todo
Create following specification:
-
:slugfield (String) - the slug will be stored as plaintext. (no need to encrypt it as it'spublic) - Create a
Fields.validate_slugfunction that validates the:slugas containing exclusively URL safe characters:abcdefghijklmnopqrstuvwxyz0123456789-_. - Invalid
:slugshould return and Error whichautoformwill display in the frontend.
e.g: "That slug is invalid, please include only valid characters to ensure that humans can read/type it:abcdefghijklmnopqrstuvwxyz0123456789-_." - We cannot perform a Database check for the uniqueness of the
:slugfrom afieldsperspective, but this should be done in the Application that is using the:slugfield to ensure that there are no duplicate/colliding URLs. This should be added to the documentation.
Thankfully there is this StackOverflow answer:
https://stackoverflow.com/questions/695438/safe-characters-for-friendly-url
Which gives most of the detail we need: ALPHA DIGIT "-" / "." / "_" / "~"

However I would exclude the ~ ("tilde") character,
because it's not immediately findable on some keyboards and a pain on mobile.
Thus the valid characters for a :slug should be: abcdefghijklmnopqrstuvwxyz0123456789-_.
Yes, the W3C Spec allows uppercase characters in URLs https://www.w3.org/TR/WD-html40-970708/htmlweb.html as per https://stackoverflow.com/questions/7996919/should-url-be-case-sensitive but how many of the top 100 websites
Ok, Amazon uses case sensitive URLs ... 🙄
e.g: https://www.amazon.com/Zero-One-Notes-Startups-Future/dp/0804139296/
although ... what really matters in an Amazon URL is the "ASIN" (:id) of the item ...
this works: https://www.amazon.com/iCan-write-anything-in-this-section/dp/0804139296/
However many ASIN's are all UPPERCASE:
e.g: https://www.amazon.com/Nintendo-Switch/dp/B01MUAGZ49/
but they still work if down-cased: https://www.amazon.com/Nintendo-Switch/dp/b01muagz49 ...
I vote that we make slug lowercase for now, and if any user requests that we allow UPPERCASE characters, we can add that later.
Note:
:slugis different from:url#16 in that:urlis the full URL
e.g: https://dwyl.com/home whereas a:slugis just the part after the domain,
e.g:home-healthy-creative-technology-co-living-community
(that's probably way too long for a:slug, but you get the idea ...)