Page numbers and URL segments

When using pagination, you may also see page numbers in URLs, like /a/b/c/page2/. The page2 portion is not considered a URL segment and is instead considered a page number. When page numbers are enabled for your template, any URLs matching the page number format will not be counted towards your URL segments. When both URL segments and page numbers are used, the page numbers always appear at the end.

  1. What are URL segments?
  2. How and where to use them
  3. Best practices
  4. Page numbers and URL segments


  • Chris

    Chris 4 years ago 32

    These url segments, although cleaner, seem just like a query string. how do they differ?

    • ryan

      ryan 4 years ago 182

      Some reasons to use URL segments rather than query strings:

      1. Pages rendered from URL segments can be cached, whereas pages rendered as the result of a query string cannot.

      2. URL segments are search engine friendly, whereas query strings are not necessarily.

      3. URL segments are sanitized automatically, since they have to follow PW page name format, whereas query strings are not.

      4. URL segments are nicer to look at, easier to read, and easier to type.

      But should you replace your use of query strings with URL segments? Nope. I would always still use query strings in these situations:

      1. The potential values you accept are unlimited. You would not want such values to benefit from caching (per item 1 above) since a cache with no limits can fill up a drive.

      2. You are in an environment where things like search friendliness and readability aren't really a factor. For instance web applications with a logged in user is likely to derive more benefit from using query strings.

      3. You need true "key=value" relationships with variables. Keep in mind URL segments are just the 'value' part. You might translate /key1/value1/key2/value2, etc., but that's more work and things to keep track of than a nice simple key=value query string.

      4. One of the biggest: if you need to allow values outside PW page name format. Keep in mind PW page names are limited to this set of characters: -_.a-z0-9. So you aren't going to want to use URL segments for a text search engine for example.

      5. The quantity of variables in the URL is unknown. URL segments are naturally limited to just a few. Whereas you could have any number of variables present in a query string.

      • Chris Falkenstein

        Chris Falkenstein 4 years ago 63

        Ryan, thanks for the informative response. and thank you for your generous offering here, pw. The more I use it the more I like it. Keep up the excellent work.

  • Alan

    Alan 3 years ago 11

    Coming from WordPress it seems to me this Would be an optimal way to use category/tags. But what can be a better use for this? =)

  • Joseph D Regan

    Joseph D Regan 2 months ago 00

    Can you use both at the same time? Query string and URL segment?

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.