francuel's avatar

Pagination system without URL parameters

Hello,

When using the pagination system that Laravel itself offers, page links look like this:

http://127.0.0.1:8000/blog
http://127.0.0.1:8000/blog?page=2
http://127.0.0.1:8000/blog?page=3

But I wanted a more friendly URL, that is:

http://127.0.0.1:8000/blog
http://127.0.0.1:8000/blog/page/2
http://127.0.0.1:8000/blog/page/3

Is there any way to do this without giving up the pagination features that Laravel already offers?

0 likes
7 replies
jlrdw's avatar

If you search, @MichalOravec has that on Github. But I suggest use as is, nothing wrong with ?page=2.

2 likes
francuel's avatar

@jlrdw It wasn't the answer I expected, I thought there was a native way to do this.

My purpose was just to make working with the canonical url attribute easier.

Thank you for your help.

1 like
jaseofspades88's avatar

What problems were you experiencing with the canonical url attribute? You can customise the pagination to act as you wish.

1 like
francuel's avatar

@martinbean I understood. Then decide to leave the canonical like this:

<link rel="canonical" href="http://127.0.0.1:8000/questoes?page=2">
1 like

Please or to participate in this conversation.