Minimal-mistakes: Disable legacy pagination in jekyll-paginate-v2

Created on 11 Sep 2017  路  25Comments  路  Source: mmistakes/minimal-mistakes

  • [X] This is a question about using the theme.
  • [ ] This is a feature request.
  • [X] I believe this to be a bug with the theme.

    • [X] I have updated all gems with bundle update.

    • [X] I have tested locally with bundle exec jekyll build.


Environment informations

  • Minimal Mistakes version: 4.5.2
  • Jekyll version: 3.5.2
  • GitHub Pages hosted: no
  • Operating system: Windows 10

Expected behavior

Tried commenting out or deleting the two pagination lines in _config.yml. Pagination on Index page still happening. When I add values to those lines, I can change them (e.g. increase number of posts from 5 to 12)

Steps to reproduce the behavior

My intent is to replace jekyll-paginiate with jekyll-paginate-v2 so I can paginate category and tag pages.

I moved my site from GitHub to netlify so I could use the gemified theme and custom plugins. This is my preferred installation.

I have gotten things to work with a forked/downloaded version of the theme, so I think it's buried in the gem's _config.yml

Stale Support

All 25 comments

The gem doesn't bundle in pages. You need to change your index file. It's likely using layout: home which pulls in some Jekyll Paginate code.

If you don't want a paginated home page use layout: archive instead and then drop in the relevant code into the body of the page.

Example:

layout: archive
---

{% for post in posts %}
  {% include archive-single.html %}
{% endfor %}

I _am_ trying to do pagination, but with the jekyll-paginate-v2 plugin.

What I can't seem to accomplish is disabling the legacy configuration in _config.yml so I can take advantage of the newer plugin.

Jekyll throws this on build:

Pagination: You are running jekyll-paginate backwards compatible pagination logic. Please ignore all earlier warnings displayed related to the old jekyll-paginate gem. 
Pagination: Detected legacy jekyll-paginate logic running. Please update your configs to use the jekyll-paginate-v2 logic. This compatibility function will stop working after Jan 1st 2018 and your site build will throw an error.

The testing I've done suggests that the default legacy config comes through when commented out:

# paginate: 12 # amount of posts to show
# paginate_path: /page:num/

Still paginates at 5. If I uncomment out, then the 12 posts show.

Could be a side affect of jekyll-data. That gem is a dependency of the theme and takes _config.yml that's in the gem and "flattens" it with your custom _config.yml.

What's probably happening is when you comment out those lines in your config it's still picking up the values in the theme's _config.yml. Try setting them to nil to zero them out.

paginate: nil
paginate_path: nil

If nil doesn't work false might.

I get it to work with jekyll-paginate-v2 here https://github.com/dev4223/ondata
It's a fork with some layout changes.

I'm on netlify, too.

@dev4223 I got it to work locally with a fork too-- just really hoping I can get it to run with the gem theme. It makes things so much cleaner.

@douglangille See my note above. You need to zero out those variables in your _config.yml. Commenting them out just reverts back to using whatever values are in the bundle theme.

Not sure if nil, false, or blank will do it, but one of them should.

Wow. jekyll-data is tenacious! I've tried nil, false, blank, an actual blank-- all with and without quotes.

It feels like this is the right track as now I get:
Config Warning: Thepaginatekey must be a positive integer or nil. It's currently set to 'nil'.

However, the 5 keeps poking through.

I think there's a bug with jekyll-paginate-v2. I used a forked version of the theme and set:

paginate: nil
paginate_path: nil

In it's _config.yml and those same errors come up.

Config Warning: The `paginate` key must be a positive integer or nil. It's currently set to '"nil"'.
Config Warning: The `paginate` key must be a positive integer or nil. It's currently set to 'nil'.

Looks to me the plugin isn't properly reading those values as nil. It's expecting not to see them at all in the config, which obviously won't work because of jekyll-data. Perhaps file an issue with jekyll-paginate-v2 to see if it can be patched.

Will do. Thanks

So after some investigation by @sverrirs, it looks like:

(a) there is some legacy paginate code in Jekyll that needs scrubbing (https://github.com/jekyll/jekyll/issues/6391), and
(b) the new paginate plugin is confirmed to be working as expected (https://github.com/sverrirs/jekyll-paginate-v2/issues/37#issuecomment-332614079).

I'm not sure where that leaves things, because the bundled config file can't be overridden by nil.

I'm out of options.

I don't know of any other way of overriding it other than using nil. Which the plugin doesn't seem to use in order to bounce it into backwards-compat mode.

I'll leave this open with the hope jekyll/jekyll addresses the hardcoded pagination bit.

Welp, the short answer for me is I'll have to move back to using the forked version rather than the gem-theme. Not ideal, but I'll get the result needed. If jekyll/jekyll addresses this, I'll try again.

Hello Guys!
I'm the author of the aforementioned plugin jekyll-data. Came across this ticket via the related ticket opened at Jekyll in response to sverrirs/jekyll-paginate-v2#37

Just thought I'd leave a clarification with regard to jekyll-data's role in this ado nevertheless.

From what i gather by reading Minimal Mistakes' gemspec it looks like the theme's _config.yml is not being bundled within the theme-gem and therefore not accessible to jekyll-data

Good point @ashmaroli. My mind was lumping _data and the _config.yml into one, but you're absolutely correct that it's not bundled with the theme gem.

:slightly_smiling_face: That said, I think the actual issue is kinda related to my fears that I'd voiced when I enhanced Jekyll itself to automatically load a theme-gem's runtime dependencies.. minimal-mistakes-jekyll lists jekyll-paginate as a runtime_dependency and therefore it gets loaded whether desirable or not.

Jekyll Core turned down my proposal for a blacklist config key to counter this, though.. (citing unnecessary confusion surrounding a whitelist and then a blacklist..)

Workaround to use jekyll-paginate-v2 instead of jekyll-paginate

The reason you're not able to use the newer version of the pagination plugin is because Jekyll 3.5+ automatically loads all of a gem-based theme's runtime-dependencies..(in our case, jekyll-paginate too)

The way around is as follows:

  1. Maintain a whitelist of all the plugins required by Minimal Mistakes. (Already provided for, here)
  2. Adjust your config file to use only the new pagination plugin. i.e. your must comment out the paginate: configuration.
  3. Replace jekyll-paginate in the whitelist with jekyll-paginate-v2
  4. Add jekyll-data to the whitelist if you're depending on default Theme-UI data files within the theme-gem.
  5. Always build / serve your site under safe mode by adding safe: true to your _config.yml or by using the CLI switch --safe

/cc @douglangille in case you want to continue using minimal-mistakes-jekyll gem

Notes:

  1. The minimal-mistakes-jekyll gem has an _includes/paginator.html include which gets included to produce the paging navigation and [lovely] UI. See the theme's _layouts/home.html layout for the calling.

    • The include refers to site.pagination_path to build the [proper] reference links to navigate between pages.
    • Note site.pagination_path refers to jekyll-paginate (version 1), not v2. Ergo, out of box, minimal-mistakes-jekyll gem is not designed to be compatible with jekyll-pagination-v2.
    • For example, if you try to use pagination outside of root path/URI / breakage will occur with pagination... unless adaptation to _includes/paginator.html has been accommodated.
    • e.g. ...{{ page.pagination.mypaginator_path | replace: ':cat', page.autopages.display_name | replace: 'page:num', '' | replace: '//', '/' | absolute_url %}}...
  2. The default _config.yml for minimal-mistakes-jekyll theme/gem does not contain configuration for jekyll-paginate-v2, which requires new/additional/different configuration to enable... both in _config.yml and then within the pages where you desire pagination, e.g.:

  • /index.html

    • ---

    • ...

    • layout: my_home_layout_pagination_ready

    • pagination:

    • enabled

    • per_page: 2

    • ...

    • ---

I was eventually able to integrate and implement:

  • minimal-mistakes-jekyll
  • jekyll-paginate-v2

    • ...along with it's AutoPages feature to generate category, tag, collection pages, etc.

It required addressing the aforementioned aspects however, which meant having the following files and adjusted outside of the minimal-mistakes-jekyll gem theme:

  • ./_layout/home.html
  • ./_layout/archive-taxonomy.html
  • ./_includes/paginator.html
  • ./index.html
  • ./_config.yml (expected)

Would very much like to see jekyll-paginate-v2 integration and capabilities without the need to maintain and manage core theme files within the site/source. Wonderful theme and offering! Thank you @mmistakes!

Because pictures make everything better:

screen shot 2017-10-17 at 9 43 22 am
screen shot 2017-10-17 at 9 43 34 am
screen shot 2017-10-17 at 9 43 44 am
screen shot 2017-10-17 at 9 43 55 am

@jaybe-jekyll Would you mind opening a new issue to track enhancing MM to support jekyll-paginate-v2? You could paste in exactly what you have above.

Thanks!

That's awesome @jaybe-jekyll. I managed to get things (pagination/autopages) to work with the gem'd theme with only minor mods. I'll add my feedback to the new issue you create.

This issue has been automatically marked as stale because it has not had recent activity.

If this is a bug and you can still reproduce this error on the master branch, please reply with any additional information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in 7 days if no further activity occurs. Thank you for all your contributions.

Was this page helpful?
0 / 5 - 0 ratings