Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create :slug field for unique URLs #31

Open
4 tasks
nelsonic opened this issue Jan 9, 2019 · 0 comments
Open
4 tasks

Create :slug field for unique URLs #31

nelsonic opened this issue Jan 9, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nelsonic
Copy link
Member

nelsonic commented Jan 9, 2019

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:

  • :slug field (String) - the slug will be stored as plaintext. (no need to encrypt it as it's public)
  • Create a Fields.validate_slug function that validates the :slug as containing exclusively URL safe characters: abcdefghijklmnopqrstuvwxyz0123456789-_.
  • Invalid :slug should return and Error which autoform will 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 :slug from a fields perspective, but this should be done in the Application that is using the :slug field 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 "-" / "." / "_" / "~"
image

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: :slug is different from :url #16 in that :url is the full URL
e.g: https://dwyl.com/home whereas a :slug is 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 ...)

@nelsonic nelsonic added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant