DEV Community

jeikabu
jeikabu

Posted on • Originally published at rendered-obsolete.github.io on

GitHub Pages Migration Part 2

This is a follow-up to my previous post about migrating to Github Pages

On Bundle and Gemfiles

As is so often the case, I figured out my problem with bundle a few hours later. While looking into something else I came across The github-pages gem- which I evidentally missed the first time I set this up- and was reminded that the Gemfile was in my own repo. When executed in the right place sudo bundle update works as expected.

Working with new tech is always a humbling experience.

On Repositories

Anyway, upgrade to Jekyll 3.7.3 and…

  Liquid Exception: No repo name found. Specify using PAGES_REPO_NWO environment variables, 'repository' in your configuration, or set up an 'origin' git remote pointing to your github.com repository. in /_layouts/default.html

ERROR: YOUR SITE COULD NOT BE BUILT:
       ------------------------------------
       No repo name found. Specify using PAGES_REPO_NWO environment variables, 'repository' in your configuration, or set up an 'origin' git remote pointing to your github.com repository.
Enter fullscreen mode Exit fullscreen mode

This Jekyll issue and the PR it referenced clarifies what is going on.

To move to github I’d added another remote git repository github (my previous bitbucket repo was origin). Like the helpful ERROR message states, I either need to set repository in _config.yml or the git remote named origin needs to point to github.com.

Simple enough.

Either seems to work. But, I need to use two github accounts, so I set repository.

Theming

Now looking at a GitHub doc on Jekyll theming.

In _config.yml switching theme: minima for theme: jekyll-theme-midnight results in lots of:

Build Warning: Layout 'post' requested in _drafts/2018/2018-08-12-github-pages-migration.md does not exist.
Build Warning: Layout 'page' requested in about.md does not exist.
Build Warning: Layout 'home' requested in index.md does not exist.
Enter fullscreen mode Exit fullscreen mode

And a blank site.

The line about index.md is straight-foward. I removed layout: home from the YAML front matter and now had an empty index page.

There’s several issues about non-existant layouts and from the Jekyll doc of overriding themes I find my minima theme has:

$ ls `bundle show minima`/_layouts
default.html    home.html   page.html   post.html
Enter fullscreen mode Exit fullscreen mode

While midnight has:

$ ls `bundle show jekyll-theme-midnight`/_layouts 
default.html
Enter fullscreen mode Exit fullscreen mode

Fine:

cp `bundle show minima`/_layouts/home.html _layouts/
cp `bundle show minima`/_layouts/post.html _layouts/
cp `bundle show minima`/_layouts/page.html _layouts/
Enter fullscreen mode Exit fullscreen mode

And everything is working.

Pagination

Having one long index with every post is starting to look a bit silly. There’s the Jekyll doc on pagination. It recommends jekyll-paginate which states that it is deprecated in favor of jekyll-paginate-v2 (which is not yet supported by GitHub Pages).

In _config.yml:

plugins:
  - jekyll-paginate
paginate: 6
Enter fullscreen mode Exit fullscreen mode

jekyll serve complains:

Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.
Enter fullscreen mode Exit fullscreen mode

Since my index.md just contains layout: home, I move _layouts\home.html to index.html (in the root of the repo). And adding the pagination templating they recommend.

Works, but now all the posts are paginated inline on the index page. Not sure that’s what I want so I’m backing that out. I’m trying to avoid fiddling with visual layout as much as possible, but I’m finding it harder and harder to retain this policy.

Comments

Despite not expecting anyone to comment (I rarely leave comments myself), I was a bit curious how they could be added.

Turns out Disqus (NB: from within China you’ll need to use VPN) is the Github Pages “way” to do this.

I setup an account and see I need to add some template magic. Figuring _layouts/post.html (which I copied from the minima template) was the place for this, I opened it and find this blurb:

{%- if site.disqus.shortname -%}
    {%- -%}
  {%- endif -%}
Enter fullscreen mode Exit fullscreen mode

Turns out the minima template has an html helper file for Disqus that includes the “universal code” and deals with the “configuration variables”. Stole that:

cp `bundle show minima`/_includes/disqus_comments.html _includes/
Enter fullscreen mode Exit fullscreen mode

And, so it points at my Disqus site, https://rendered-obsolete.disqus.com, as per this issue to _config.yml add:

disqus:
  shortname: rendered-obsolete
Enter fullscreen mode Exit fullscreen mode

Something else to watch out for is the and jekyll.environment == "production" at the top of disqus_comments.html. Jekyll defaults to a development environment, so you either need to comment that bit out or run things with:

JEKYLL_ENV=production bundle exec jekyll serve
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
talonx profile image
Hrish B

Thanks. The pagination tip helped me.