SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,757
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How big should a Slug be?

    What is a reasonable field size for a "Slug" (e.g. www.MySite.com/articles/why-incorporating-your-business-makes-sense)

    Right now, I have a VARCHAR(100) chosen.

    Thoughts?

    Thanks,


    Debbie

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    VARCHAR(255) is exactly the same as VARCHAR(100) except that it will hold a larger value

    for some columns, where you anticipate a chance of needing to store a value larger than 255 characters, you might want to choose TEXT instead (this is handled differently internally than a VARCHAR)

    but slug isn't one of them
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,757
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    VARCHAR(255) is exactly the same as VARCHAR(100) except that it will hold a larger value

    for some columns, where you anticipate a chance of needing to store a value larger than 255 characters, you might want to choose TEXT instead (this is handled differently internally than a VARCHAR)

    but slug isn't one of them
    Except that a VARCHAR(255) allows up to 255 characters... *gasp* And I don't want slugs to be that long. (Would you?!)

    I am thinking that if you can't say it in 100 characters then you need to re-think things. But that is just me?!


    Debbie

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    that sounds fine

    make sure you add code to test the length of any proposed slug, and issue a user-friendly message instead of just storing the data into VARCHAR9100) because it'll get truncated and you might not notice
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,757
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    that sounds fine

    make sure you add code to test the length of any proposed slug, and issue a user-friendly message instead of just storing the data into VARCHAR(100) because it'll get truncated and you might not notice
    Yep, I had the same idea earlier today.

    Okay, sounds good.

    BTW...

    This may sound like a funny question, but does Google have a limit on the length of what we are calling a "slug"?

    By that, I mean does Google maybe ignore the part of the slug over a certain number of characters when indexing and what-not?!

    So, if my slug was...
    Code:
    i-really-like-reading-associated-press
    ...but Google chopped things off after 25 character, the to Google, it would be...
    Code:
    i-really-like-reading-ass
    (And, hey, who doesn't?!)


    Debbie

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    i don't think google knows what a slug is, so why would google truncate it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,757
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    i don't think google knows what a slug is, so why would google truncate it?
    One of the key reasons for creating slugs is that Search Engines are supposed to like them.

    I don't know how, but Google certainly uses the URL - especially the slug - to index things.

    So, if Google had a limit of 25 characters, then it would index

    i-really-like-reading-ass
    instead of indexing...

    i-really-like-reading-associated-press
    And it might think my website or at least the web page in question about a topic entirely different than what it actually is about.

    The logic is the same as what would happen if your Title or Description got chopped off.

    If your Title read...

    This is a really really awesome web page that is many focus on dealing with CSS Tips
    ...then you would get indexed the same as if you had a title of...

    CSS Tips & Tricks
    Follow me?!


    Debbie

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    i understand that search engines know what urls are

    i don't think they know what slugs are
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •