1

I built my personal site using Jekyll (repository).

I created a plugin to retrieve information from my Medium account and populate my site's "Blog Posts" page, this is the plugin. This plugin creates a collection called medium_posts_json which I iterate over in my blog posts page.

I am also using the Jekyll Actions GitHub action because the vanilla GitHub pages do not support custom plugins. In order to use this action I added a workflow file here.

This GitHub action pushes the built site into a branch called gh-pages, and when I look at the page with the generated Blog Posts it contains all expected entries and that my plugin worked successfully (the list in the Blog Posts page is populated using the plugin I created).

The problem is that this is not the page presented on the live site! In my live site, the Blog Posts page is empty, this means that the HTML file in my gh-pages branch is not the same as the live one.

Why is that? Isn't GitHub supposed to host the content of the branch I specified? How do I even start debugging this? When I build the website locally and upload the static contents using .nojekyll it works just fine, but I wanted to use the GitHub action to automate this process, so I won't have to rebuild manually every time I post on Medium.

Thanks.

Christian
  • 4,902
  • 4
  • 24
  • 42
erap129
  • 910
  • 1
  • 8
  • 17
  • The master branch contains the source files for the build. The `gh-pages` branch contains the build artifacts (the static site files) and is generated automatically by GitHub Actions. That's why I'm not really sure I understand what you did :) The site should work as-is after I run the action because I want to be able to run it automatically every X days. And indeed, the `gh-pages` content seems fine to me, it's just that it doesn't appear in the browser (for the blog posts page). – erap129 Nov 01 '22 at 04:41
  • I have deleted my previous comment. I was confused because of the paths for the CSS. I have read a bit, see my answer. Interesting challenge, read a lot about the new way of deploying pages with actions. Found old SO posts like [this](https://stackoverflow.com/questions/72079903/do-i-need-the-pages-build-deployment-github-action-when-i-have-another-action-f) that confused me. – Christian Nov 01 '22 at 23:28
  • 1
    I think the missing link, as you described, was setting the "built-from" setting in Github to `gh-pages`. Thanks for all the effort! – erap129 Nov 02 '22 at 05:12

1 Answers1

2

GitHub will not host the content from the branch when you do not deploy it.

The GitHub action you use ( https://github.com/helaili/jekyll-action) is triggered when a commit is pushed to master but it only

  • builds the site.
  • copies the _site content to the target branch (gh-pages).

Because your workflow is only triggered on commit, you need to set up something to run the build every x day, e.g. a runner.

I have forked your repo and set up the action as you did:

name: Build and deploy Jekyll site to GitHub Pages

on:
  push:
    branches:
      - master 

jobs:
  github-pages:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }}
          restore-keys: |
            ${{ runner.os }}-gems-
      - uses: helaili/jekyll-action@2.4.0    # Choose any one of the Jekyll Actions
        with:                                # Some relative inputs of your action
          token: ${{ secrets.JEKYLL_PAT }}
          target_branch: 'gh-pages'
        env:
          JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}

To get it running, I have used the default GitHub pages deployment action to deploy the page, as you can see here: https://cadamini.github.io/erap129.github.io/ (follow the link on the index to see the blog posts).

In GitHub, I have configured that the site is built from the gh-pages branch (root folder):


enter image description here


Christian
  • 4,902
  • 4
  • 24
  • 42