forestryio / jekyll-menus

A menus (site navigation) plugin for your Jekyll website that also works with https://forestry.io (Jekyll CMS)
MIT License
134 stars 27 forks source link

Problems Loading Custom Menu Items with GitHub Pages #19

Closed oDinZu closed 3 years ago

oDinZu commented 3 years ago

Hi, I have configured and made use of your jekyll-menus plug-in and everything works locally, but on push to GitHub pages, the menu items does not populate. Would you know if your plug-in is compatible with GH Pages? Below is the code used; as said before, the linksl appear locally. The version of Jekyll I am using is 4.0.

header.html

    <nav class="links">
      <ul>
        {% for item in site.menus.header %}
        <li class="menu-item-{{ loop.index }}">
          <a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
        {% endfor %}
      </ul>
    </nav> 

menus.yml

---
header:
  - url: /
    title: News
    identifier: header
  - url: #
    title: About
    identifier: header
  - url: #
    title: Projects
    identifier: header
  - url: #
    title: Volunteer
    identifier: header
  - url: #
    title: Donate
    identifier: header
---
DirtyF commented 3 years ago

You have to build your site with GitHub Actions to use non-whitelisted Jekyll plugins on GitHub Pages: https://jekyllrb.com/docs/continuous-integration/github-actions/

oDinZu commented 3 years ago

I setup GitHub Actions, but have had no luck getting the menus to populate. Would you have a working example with gh-pages branch for Jekyll website and this plug-in?

I tested 9 different configuration setups and searched through the docs, plus if anyone else had any issues like this with Jekyll 4.0. I found this: https://github.com/helaili/jekyll-action/issues/45 and is closest issue I have had similar to mine.

I was unable to successfully build with Jekyll GitHub Actions 2.0.3 or 2.0.2; 2.0.1 enabled me to compile successfully, but even after success, it didn't merge repo into the gh-pages branch as the documentation states; plus the Jekyll site with this plugin didn't populate the menu.

When I push changes, I push them to master repository, then GH actions checks, then is suppose to push to gh-pages to allow more possibility with Jekyll plugins and other features.

Below, I have added some code and also a link to my repository. Repository: https://github.com/Galactic-Society/galactic-society.github.io/ (the GH-Pages setting is set to master @ /root) Also, the repository is an organization and is public.

github-pages.yml

name: Testing the GitHub Pages publication

on:
  push

jobs:
  jekyll:
    runs-on: ubuntu-16.04
    steps:
    - uses: actions/checkout@v2

    # Use GitHub Actions' cache to shorten build times and decrease load on servers
    - uses: actions/cache@v1
      with:
        path: vendor/bundle
        key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
        restore-keys: |
          ${{ runner.os }}-gems-

    # Standard usage
    - uses:  helaili/jekyll-action@2.0.1
      env:
        JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}

    # Specify the target branch (optional)
    - uses: helaili/jekyll-action@2.0.1
      env:
        JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}
      with:
        jekyll_src: 'gh-pages'

logs

...
      Generating... 
       Jekyll Feed: Generating feed for posts
DEPRECATION WARNING on line 7 of /github/workspace/_scss/libs/_breakpoints.scss:
!global assignments won't be able to declare new variables in future versions.
Consider adding `$breakpoints: null` at the top level.

                    done in 0.92 seconds.
 Auto-regeneration: disabled. Use --watch to enable.
Jekyll build done
Cannot publish on branch master
DirtyF commented 3 years ago

Please use the GitHub community form to get help on how to run GitHub Actions, we don't provide support for this.

oDinZu commented 3 years ago

When using this code: (Only thing changed was the version numbers to 2.0.1 and v1 for cache.

name: Build and deploy Jekyll site to GitHub Pages

on:
  push:
    branches:
      - master

jobs:
  github-pages:
    runs-on: ubuntu-16.04
    steps:
      - uses: actions/checkout@v1
      - uses: helaili/jekyll-action@2.0.1
        env:
          JEKYLL_PAT: ${{ secrets.JEKYLL_PAT }}

the build is successful, but does not push or create to gh-pages and populates this error:


error: src refspec ***@github.com/Galactic-Society/galactic-society.github.io.git does not match any

error: failed to push some refs to 'https://'
oDinZu commented 3 years ago

@DirtyF I got the gh-pages to successfully build with jekyll-actions. I am still unsure what the problem is, but the solution was to create a new organizational account and fork the repository, then redo the token and enable gh-pages in the settings.

Furthermore, the jekyll-menus plugin is still not publishing links to the website. You can view the results here: https://galacticsociety.github.io/ there should be links directly to the right of the header website name. Screenshot from 2020-08-28 15-45-04

https://github.com/GalacticSociety/galacticsociety.github.io/runs/1043056609?check_suite_focus=true

oDinZu commented 3 years ago

Okay, to make sure it wasn't jekyll-menus, i tested time ago plugin that worked as a quickstart test. I setup the plugin and had same issues with it not displaying.

Furthermore, I needed to switch my org. settings to gh-pages branch to be displayed to enable jekyll-menus to work.

So much difficulties getting something like this setup for the first time. I spent almost 3 days troubleshooting and pondering on what is going on. I am still unsure why creating another new organizational account solved the problem for the github-actions. I am still unsure why v2.0.2+ of jekyll actions doesn't work when using githubs actions.

In the instructions on the jekyll core website, maybe add a tip saying "after actions is setup and the new gh-pages branch is created, remember to switch from master to the gh-pages in the account repository to populate other jekyll plugins not whitelisted on github pages.