SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Hybrid View

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

    Question about building a Pretty URL

    Recently, I added on to my Pretty URL to handle *sorting* of Article Summaries, and things now look like this...
    Code:
    http://local.debbie/finance/markets/by-date/desc/3
    http://local.debbie/finance/markets/by-title/asc/1
    http://local.debbie/finance/markets/by-rating/desc/5
    Where the Sort-Field = 'by-date', Sort-Order = 'desc', and Page-Number = '3'


    Before going to bed last night, I realized that I forgot to add Filtering, and would like to further expand my Pretty URL like this...
    Code:
    http://local.debbie/finance/markets/editors-choice/by-date/desc/3
    http://local.debbie/finance/markets/last-day/by-date/desc/3
    http://local.debbie/finance/markets/last-month/by-date/desc/3
    Where the Filter = 'editors-choice', Sort-Field = 'by-date', Sort-Order = 'desc', and Page-Number = '3'

    Does that URL look okay, or is it too unwieldy?

    Sincerely,


    Debbie

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Personally, I'd put the Sort-Field, Sort-Order, and Filter in the query string instead of directly in the URL because:

    1) They don't change what is on the site, only how it is displayed (pretty much the definition of the query string)
    2) The fields are optional, which makes them perfect candidates for query string
    3) You are creating completely different URLs for the same data, which is not very wise SEO-wise
    4) You are creating very deep URLs which is again is not very wise SEO-wise

    So I would do something like

    /finance/markets/3?sort=date&sort_dir=desc&filter=editors-choice

    This to me clearly states that I'm on page 3 of finance/markets, but I've changed it so that it's displaying by date descending, and filters on editor-choice only.
    Also, with query strings, I can remove any parameter I don't like, and the URL is still valid! With your scheme it isn't all that clear what can just be removed and what not.

    Whatever you decide to do, make sure you point to a canonical URL in any URL that has different sorting (not for filtering, it doesn't apply there)
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ScallioXTX,

    I hope you aren't about to break my website design...


    Quote Originally Posted by ScallioXTX View Post
    Personally, I'd put the Sort-Field, Sort-Order, and Filter in the query string instead of directly in the URL because:

    1) They don't change what is on the site, only how it is displayed (pretty much the definition of the query string)
    2) The fields are optional, which makes them perfect candidates for query string
    3) You are creating completely different URLs for the same data, which is not very wise SEO-wise
    4) You are creating very deep URLs which is again is not very wise SEO-wise

    So I would do something like

    /finance/markets/3?sort=date&sort_dir=desc&filter=editors-choice

    This to me clearly states that I'm on page 3 of finance/markets, but I've changed it so that it's displaying by date descending, and filters on editor-choice only.

    Also, with query strings, I can remove any parameter I don't like, and the URL is still valid! With your scheme it isn't all that clear what can just be removed and what not.
    You've totally lost - and scared - me on this...


    First off, the sample URLs I posted above are created from an Apache mod_rewrite file that took an enormous amount of work to make things look pretty...

    I was under the impression that Query Strings were bad because they look crude, are harder to read, and even can expose the structure of your website to hackers.

    Before I started adding on the capability to Filter and Sort, my website/URL was set up like this...


    When a user goes to a Section, the URL looks like this...
    Code:
    http://www.debbie.com/finance/

    When a user goes to a Subsection, the URL looks like this...
    Code:
    http://www.debbie.com/finance/economy/

    When a user wants to read an Article, the URL looks like this...
    Code:
    http://www.debbie.com/finance/economy/fastest-growing-small-business-sectors-for-2013

    As mentioned above, after building my Subsection home page - which lists Article Summaries for that Subsection - I realized that I needed to break things up into maybe 20 Article Summaries per Page, and that means I need to provide a way for people to Filter and Sort to get to the Articles they want to read.


    So I figured the following would be a "pretty" and logical way for users to see how Articles were being sorted on the Subsection home page...
    Code:
    http://www.debbie.com/finance/economy/by-date/desc/3

    You are saying that is bad??


    Quote Originally Posted by ScallioXTX View Post
    Whatever you decide to do, make sure you point to a canonical URL in any URL that has different sorting (not for filtering, it doesn't apply there)
    I read that link and it didn't really make sense...


    Again, I thought what I was doing was "good"...

    Sincerely,


    Debbie

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    You are saying that is bad??
    I'm not saying it's bad, I'm saying I wouldn't do it that way, for reasons outlined above.
    Indeed, some say that query strings are a Bad Thing (tm), but that doesn't mean they don't have their place. For stuff like this I really find the query string a more appropriate location. Others may disagree on this of course.

    Regarding the query string being unreadable and showing stuff to hackers, that only applies if you do everything via the query string, i.e.

    mydomain.com/?cat=1

    But I'm not suggesting that. I'm suggesting a nice structure for the base url, with query string parameters for the sorting and filtering

    As for your mod rewrite, you'd just have to remove the sort and filter specific rules. And there is nothing you need to do to add query strings to your URLs, that works out of the box with mod_rewrite.

    Quote Originally Posted by DoubleDee View Post
    I read that link and it didn't really make sense...
    Basically what it's saying is if that have you have different pages with the same info displayed differently (i.e. one URL with articles sorted ascending, another URL with the same articles sorted descending), you have to pick one of them and deem that the "canonical" version (mostly people use the version you'd see if you don't apply sorting or filtering manually). Suppose we call the one that is sorted ascending canonical, then we'd have to indicate on the page where the articles that are sorted descending that the ascending version is canonical. So you'd place this on the descending page

    Code:
    <link rel="canonical" href="http://blog.example.com/same/articles/but/sorted/ascending" />
    Then when a search engine crawls you page with the articles sorted descending it knows not to index that page, but to index the page where the articles are sorted ascending instead. If you let google index both pages there is a chance you will get a duplicate content penalty [since the pages contain the same content but in a different order].

    Makes sense?
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,764
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ScallioXTX,

    I guess I'd rather have people challenge me and make me a better web developer, but it sure can be frustrating at times!!


    Quote Originally Posted by ScallioXTX View Post
    I'm not saying it's bad, I'm saying I wouldn't do it that way, for reasons outlined above.
    Indeed, some say that query strings are a Bad Thing (tm), but that doesn't mean they don't have their place. For stuff like this I really find the query string a more appropriate location. Others may disagree on this of course.
    So let's say I took your advice and had this...
    Code:
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=1
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=2
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=3

    Sorry if you explained before, but why wouldn't Google consider these 3 pages as similar or duplicates versus this...
    Code:
    www.debbie.com/finance/economy/by-date/asc/1
    www.debbie.com/finance/economy/by-date/asc/2
    www.debbie.com/finance/economy/by-date/asc/3

    Off Topic:


    Finance is the Section and Economy is the Subsection - and not a file - so shouldn't it be...
    Code:
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=1
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=2
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=3



    Quote Originally Posted by ScallioXTX View Post
    Regarding the query string being unreadable and showing stuff to hackers, that only applies if you do everything via the query string, i.e.

    mydomain.com/?cat=1

    But I'm not suggesting that. I'm suggesting a nice structure for the base url, with query string parameters for the sorting and filtering
    Okay.


    Quote Originally Posted by ScallioXTX View Post
    As for your mod rewrite, you'd just have to remove the sort and filter specific rules. And there is nothing you need to do to add query strings to your URLs, that works out of the box with mod_rewrite.
    Yeah, I know, but I worked *so hard* to craft this perfect mod_rewrite, and now you are saying not to use it because it will hurt me in Google's eyes?!



    Quote Originally Posted by ScallioXTX View Post
    Basically what it's saying is if that have you have different pages with the same info displayed differently (i.e. one URL with articles sorted ascending, another URL with the same articles sorted descending), you have to pick one of them and deem that the "canonical" version (mostly people use the version you'd see if you don't apply sorting or filtering manually). Suppose we call the one that is sorted ascending canonical, then we'd have to indicate on the page where the articles that are sorted descending that the ascending version is canonical. So you'd place this on the descending page

    Code:
    <link rel="canonical" href="http://blog.example.com/same/articles/but/sorted/ascending" />
    Then when a search engine crawls you page with the articles sorted descending it knows not to index that page, but to index the page where the articles are sorted ascending instead. If you let google index both pages there is a chance you will get a duplicate content penalty [since the pages contain the same content but in a different order].

    Makes sense?
    I guess where I am also confused is that most of my content is *dynamic*.

    A user would have to choose to go to Sort by Date, in Descending Order and land on Page 3.

    So how can a Google bot crawl webpages that don't exist as physical files?

    Sincerely,


    Debbie

    P.S. Opinions from other gurus are welcome on this topic!!!

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by DoubleDee View Post
    and had this...
    Code:
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=1
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=2
    www.debbie.com/finance/economy?sortfield=by-date&sortorder=asc&page=3

    Sorry if you explained before, but why wouldn't Google consider these 3 pages as similar or duplicates versus this...
    Code:
    www.debbie.com/finance/economy/by-date/asc/1
    www.debbie.com/finance/economy/by-date/asc/2
    www.debbie.com/finance/economy/by-date/asc/3
    Google doesn't consider pages similar or duplicate based on URL, but only based on the content on that pages. You can structure the URL all you like as far as google is concerned (ever noticed how ugly amazon's URLs are? They still rank fine). Pretty URLs are just a hint that the content is static, while query strings are hint that content is dynamic.

    Quote Originally Posted by DoubleDee View Post
    Off Topic:


    Finance is the Section and Economy is the Subsection - and not a file - so shouldn't it be...
    Code:
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=1
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=2
    www.debbie.com/finance/economy/?sortfield=by-date&sortorder=asc&page=3
    Depends on who you ask. It's a matter of taste really. It's possible to argue either way.

    Quote Originally Posted by DoubleDee View Post
    I guess where I am also confused is that most of my content is *dynamic*.

    A user would have to choose to go to Sort by Date, in Descending Order and land on Page 3.

    So how can a Google bot crawl webpages that don't exist as physical files?
    Google doesn't care about files or directories, all google cares about are URLs. So google can crawl both page 1 ascending and page 3 descending, and since they contain the same content, it's wise to put a canonical from page 3 descending to page 1 ascending (and from page 2 descending to page 2 ascending, etc)

    While we're at it, you may want to add some pagination hints as well http://googlewebmastercentral.blogsp...d-relprev.html
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •