GetPublii / Publii

The most intuitive Static Site CMS designed for SEO-optimized and privacy-focused websites.
https://getpublii.com
GNU General Public License v3.0
6.21k stars 416 forks source link

[Bug]: Pagination broken links #1197

Closed freezenova closed 1 year ago

freezenova commented 1 year ago

Operating system

Windows

Publii version

0.42.0 (build 16217)

Post editor

None

Bug description

Hello,

Website doesn't use pretty links and the always add index.html in URLs is checked. Pagination is generating broken links. There are some links in pagination that get a / at the end of the link.

class=”pagination-active“>1 <a href=”./page/2/index.html/“>2 <a href=”./page/3/index.html/“>3<a href=”./page/2/index.htmlclass=”pagination__nex

The links from pagination similar to “./page/2/index.html/” are generating broken links

The slash / at the end of the link isn’t compatible with my webhost.

Thank you.

Steps to reproduce

Use pretty links - not checked Always add index.html in URLs - checked Pagination: infinite scroll or pages. (both options generate the same links) Broken links appear with / The bug appears after deployment to server, I couldn't reproduce it in preview. After checking preview and output directory, this issue appears only in output directory.

I think the issue is on: Publii-master\app\back-end\modules\render-html\handlebars\helpers\page-url.js

line 31 current line: if(!rendererInstance.previewMode) { fix: if(!rendererInstance.previewMode && !rendererInstance.siteConfig.advanced.urls.addIndex) {

Thank you.

Relevant log output

No response

freezenova commented 1 year ago

I think the issue is on: Publii-master\app\back-end\modules\render-html\handlebars\helpers\page-url.js

line 31

current line: if(!rendererInstance.previewMode) {

fix: if(!rendererInstance.previewMode && !rendererInstance.siteConfig.advanced.urls.addIndex) {

I have tested with this fix and it seems to solve the issue. Please check this. Thank you.

dziudek commented 1 year ago

Hi @freezenova - to be honest - I am unable to reproduce this issue on my local instance, but yes - the suggested fix should be used according how the code works, so I have added this patch to Publii v.0.42.1 planned for the next week :)