We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Pagination and rel="canonical"

How Do I?

Erick Flatcher's avatar
Erick Flatcher
27 posts
one year ago
Erick Flatcher's avatar Erick Flatcher

Pagination creates additional pages. For example, if the site has correct pages with numbers P24/P48/P72, then pages with P23/P75/P12345667890 may multiply. This can happen for various reasons.

We need to add the rel=canonical meta tag.

For example:

Pagination creates pages with 24 elements. The second page will have the address /P24, the third /P48, the fourth /72, and so on. We need to get this P24/P48/P72 value to insert into rel-canonical The problem is that {paginate}{current_page}{/paginate} in the {exp:channel:entries} tag and limit=1 will give numbers P25/P49/P73.

How to get the correct number? Is it possible to use a mathematical operation (-1 from the current_page value without using Add-on and PHP?

       
Erick Flatcher's avatar
Erick Flatcher
27 posts
one year ago
Erick Flatcher's avatar Erick Flatcher

It’s probably difficult. It’s easier to avoid any duplicates from appearing by not allowing them to appear by specifying clear instructions for the last segment (P00) in the tag. I’ve already decided that.

If you are interested… I have make pagination pages by 50 (paginate P50, P100, P150, P200…). And set the following condition:

{if segment_3 == "" OR segment_3 $= "00" OR segment_3 $= "50"}{if:else}{redirect='404'}{/if} {if segment_4}{redirect='404'}{/if}

here if the page number ends neither 00 or 50, then a 404 error is issued. If adiitional segment appears, then also a 404.

       
enddote's avatar
enddote
1 posts
one year ago
enddote's avatar enddote

the provided condition checks whether the page number ends in “00” or “50” and if there are no additional segments beyond the page number. How can I handle cases where the user enters a non-numeric segment_3?

       
Erick Flatcher's avatar
Erick Flatcher
27 posts
one year ago
Erick Flatcher's avatar Erick Flatcher

The above condition will work. The non-numeric segment also ends with neither 00 nor 50.

? 1
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.