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

Exclude Pagination Pages #163

Closed
amalucelli opened this issue Mar 18, 2017 · 8 comments

Comments

Projects
None yet
9 participants
@amalucelli
Copy link

commented Mar 18, 2017

Is there any way to exclude pagination pages that are generated by jekyll-paginate?

I've already tried to change the order of gems, but didn't worked.

@pathawks

This comment has been minimized.

Copy link
Member

commented Mar 18, 2017

You are right; this is a very common use case.

We should probably take care of this in the jekyll-paginate plugin though.

@fabiomux

This comment has been minimized.

Copy link

commented Apr 19, 2017

Yes setting paginate_path as whatever/:num and using Jekyll defaults to assign sitemap to false for the whatever path. For instance i used:

paginate_path: blog/page/:num
defaults: 
  - scope:
      path: "blog/page"
    values:
      sitemap: false
@benbalter

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2017

Should pagination pages be excluded by default?

@DirtyF

This comment has been minimized.

Copy link
Member

commented Apr 19, 2017

Should pagination pages be excluded by default?

It's not mandatory.
https://support.google.com/webmasters/answer/1663744?hl=en

@amalucelli

This comment has been minimized.

Copy link
Author

commented Apr 19, 2017

Thanks @fabiomux, your example helped me to exclude the pagination pages.

I also couldn't keep the default path that jekyll-paginate generates (/page:num), because from I could see path in defaults > scope don't interpret :num or any regular expression, so I had to change to /page/:num.

My configuration ended like this:

paginate: 2
paginate_path: "/page/:num"
defaults:
  -
    scope:
      path: "page"
    values:
      sitemap: false

@amalucelli amalucelli closed this Apr 19, 2017

@mpchadwick

This comment has been minimized.

Copy link

commented Jan 15, 2018

Just wanted to leave this note for anyone else who winds up on this thread...front matter defaults work pretty well for this, but depending on your paginate path you may wind up in a scenario where removing paginated URLs also removes your main blog landing page. That is what happened to me, when I was using paginate_path: "/blog/:num", but also had my main blog page at /blog/.

In this case you'll need to change your paginate_path, but this means that your old paginated URLs will 404. You can solve this by redirecting them with jekyll-redirect-from. I wound up creating a very simple bash script to create all the all redirects

#!/usr/bin/env bash

count=$1
for ((i=2; i<=count; i++)); do
	mkdir blog/$i
	echo "---" > blog/$i/index.html
	echo "redirect_to: /blog/page/$i" >> blog/$i/index.html
	echo "sitemap: false" >> blog/$i/index.html
	echo "---" >> blog/$i/index.html
done

I had 19 paginated URLs at that time, so just run it like this

$ ./jekyll-pagination-redirects 19

Hope this helps someone. I also did a more detailed write up on this on my blog.

https://maxchadwick.xyz/blog/removing-paginated-urls-from-jekyll-sitemap

@alvarotrigo

This comment has been minimized.

Copy link

commented Mar 16, 2018

Why would we be interested in getting rid of the pagination in the sitemaps.xml?
We might be using a 10 days cache and we want to tell google to recrawl the page.

Wouldn't adding a lastmod property help google recrawl the URL, which will contain links to new post?

I'm noticing Google is not updating my page as quick as it should. And that's leasing to articles not being indexed quickly.

Right now I have:

<url>
<loc>https://mypage.com/blog/page/4/</loc>
</url>
<url>
<loc>https://mypage.com/blog/myarticle.html</loc>
<lastmod>2017-11-20T13:05:38+01:00</lastmod>

Why is not lastmod added in the page/4/? Or for that matter, in the /blog/ index?

@xRahul

This comment has been minimized.

Copy link

commented May 14, 2018

Excluding of Pagination pages from page 2 onwards is not working for jekyll-paginate-v2.

Path: posts/page/:num

Tried:

  -
    scope:
      path: "posts/page/*" # "posts/page/*/**" "posts/page/" "posts/page"   
    values:
      sitemap: false

Repo: xRahul.github.io

@jekyll jekyll locked as resolved and limited conversation to collaborators May 14, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.