问题原文
原帖链接 · Arth · CC BY-SA 3.0
I'm using the Yii Framework, with Bootstrap 3, and have noticed the default pagination behavior on the first and last pages is a little strange.
On page 2 of 3 the links look like:
< Prev | 1 | 2 | 3 | Next >
On the first page (page 1) the < Prev link is hidden (not disabled or removed), but is capped to point at the first page (page 1) again.
On the last page (page 3) the Next > link is hidden, but is capped to point at the last page (page 3).
The current page link also has the CSS cursor:default but does allow clicks.
To help the crawlers I have added rel="next/prev" to the relevant links.
I am tempted to remove the next and previous link entirely on the first and last page, respectively, and to disable the current page link (or even change it to a span). Would this be advisable? I would have thought this would make more sense to a crawler.
Is there a reason for the framework to include these hidden capped links on the page? It seems to have been deliberately coded in.
UPDATE
OK, so I just read up on it a bit more.
I thought the rel="next/prev" was supposed to be added to the link (<a>) tags in the body, not as it clearly states to additional link (<link>) tags in the head.. which was particularly foolish of me.
This was the main source of my concern, but I guess the question is still valid, so I will let it stand!
已采纳解答
原帖链接 · unor · CC BY-SA 3.0
The best practice is to omit the previous link (on the first page) and the next link (on the last page), because
- user agents without CSS support will display them, which might confuse users
- having them is pointless
The link to the current page would ideally be omitted, too, because
- user agents without CSS support will display it in the same way like the other links, so users might not be able to tell on which page they currently are
- having it is pointless
Having or not having these links should have no effect on SEO, though.
I can’t imagine any reason why having these hidden links would be a good idea. My guess (without checking their code) is that they kept them because it was easier to implement it like that.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
