Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination doesn't work when Ghost URL is set to a subpath #28

Closed
trostli opened this issue Nov 17, 2023 · 1 comment
Closed

Pagination doesn't work when Ghost URL is set to a subpath #28

trostli opened this issue Nov 17, 2023 · 1 comment

Comments

@trostli
Copy link

trostli commented Nov 17, 2023

I have configured my Ghost blog to be hosted on a subpath such as https://example.com/blog/.

However with the Source theme the link to see the next page of posts is linked as https://example.com/page/2

Whereas I believe it should link to as https://example.com/blog/page/2

Looks like the culprit is this line:

<a href="/page/2">See all {{> "icons/arrow"}}</a>

I've solved it for now by using the following Code injection in my admin panel:

<script>
  document.addEventListener('DOMContentLoaded', function () {
      var currentUrl = window.location.href; // Get current URL
      var appendUrl = "page/2"; 
      var newUrl = currentUrl + appendUrl;
      var link = document.querySelector('.gh-more a');
  
      link.href = newUrl; // Set the href attribute
  });
</script>
@trostli trostli changed the title Pagination doesn't work with URL set to a subpath Pagination doesn't work when Ghost URL is set to a subpath Nov 17, 2023
minimaluminium added a commit that referenced this issue Nov 21, 2023
refs #28

- when the archive page links to a relative path, the URL doesn't work when a site set to a subpath
- this makes the archive page URL absolute
@minimaluminium
Copy link
Member

Hey, thanks for reporting the issue! This is now fixed in d22775c.

While the JS solution you've provided is great, there's a built-in setting {{@site.url}} which suits better in this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants