Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
Hi,
I face issues with pagination. Indeed, even though it's displayed correctly, when I click on one of them, it returns my blog homepage which is not what you expect if you click on this kind of button.
I followed this tutorial to integrate pagination inside my template.
For more context, I'll post my code in my listing template
<!-- Gather blog posts from the newest to the oldest -->
Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
Hey @kejoff,
I took a look here and the part that is breaking the pagination is
{% if topic %}
{% set rec_posts = blog_recent_topic_posts('2641305117', topic, 9) %}
{% else %}
{% set rec_posts = blog_recent_posts('2641305117', 9) %}
{% endif %}
{% for rec_post in rec_posts %}
Is there a reason you're setting these variables to compare in your for loop? Because technically, you are setting the var to be the same thing, except one includes a topic parameter, which seems like extra work because If you just run your for loop as:
{% for content in contents %}
you should still have access to check a post's topics. You can also control how many posts display/per page in your content settings
If that beginning part is in there for a reason, could you please explain? The only reason I think you'd have it in there for is to style the top blog post, but that doesn't seem to be the case.
If you would like to see how I got it wroking for me, you can find my template, named: FINALCAD - Listing Articles (Blog) - Ty From HubSpot in your portal.
Look forward to hearing back and hopefully we can get this solved for you!
I took a look at your blog page and the tutorial you provided, I noticed you removed the <nav> element from the tutorial. I believe this is why you were having issues with your pagination. Once you created it as a div, you lost the default interaction that <nav> has with links. I rewrote you snipped with all the same classes, except for I created it in this structure.
With this structure, you will keep your div and span styling, but it will include the nav tag's interactions. Also, make sure you have enough articles to actually push to the second page, you can check this in Content Settings > Blog Settings. If you do, it should automatically create your page 1 and page 2 elements.
Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
Thanks for your answer but the issue is not the fact that I do not have any pagination. My problem here is the fact that when I click on one of the pagination button it returns me back to the blog homepage. It is more a link issue than nav issue.
Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
Do you have a link to the page you are trying this on? Also do you mind if I hop into your portal and clone your page to try and get something working for you?
Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
Hey @kejoff,
I took a look here and the part that is breaking the pagination is
{% if topic %}
{% set rec_posts = blog_recent_topic_posts('2641305117', topic, 9) %}
{% else %}
{% set rec_posts = blog_recent_posts('2641305117', 9) %}
{% endif %}
{% for rec_post in rec_posts %}
Is there a reason you're setting these variables to compare in your for loop? Because technically, you are setting the var to be the same thing, except one includes a topic parameter, which seems like extra work because If you just run your for loop as:
{% for content in contents %}
you should still have access to check a post's topics. You can also control how many posts display/per page in your content settings
If that beginning part is in there for a reason, could you please explain? The only reason I think you'd have it in there for is to style the top blog post, but that doesn't seem to be the case.
If you would like to see how I got it wroking for me, you can find my template, named: FINALCAD - Listing Articles (Blog) - Ty From HubSpot in your portal.
Look forward to hearing back and hopefully we can get this solved for you!
Hubspot Blog (HubL): Pagination leads to the blog homepage only
SOLVE
That's great news! Over the time I've worked on the COS and blog pages, I found it alot easier to style "first-items" through either CSS using something like:
Then you could style that first post off of the "featured-post" class instead. This function will run once on every blog page, so if you go to page 2, it will run it again, and so on.
Glad I could help! Let me know if you have anymore questions!