yous / whiteglass

Minimal, responsive Jekyll theme for hackers

Home Page:https://yous.github.io/whiteglass/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

regarding post categories

dotkay opened this issue · comments

I can get the post categories working when I build it locally, but they don't show up in github pages :-( can you please help? Thanks,

Hi, actually this theme uses jekyll-archives gem, which is not supported by GitHub Pages. This is the reason of using Travis CI to build the website.

The only thing you need to change in .travis.yml is env.global.secure value. Go to 'Settings > Personal access tokens' in GitHub, and generate a new token. Then using travis gem, encrypt that token in your blog repository.

gem install travis
travis encrypt TOKEN="yourtoken"

Then it'll output something like secure: "...", then update the .travis.yml with the value.

Thanks again.
I tried travis encrypt TOKEN="..." but it throws the following:

repository not known to https://api.travis-ci.org/: dotkay/dotkay.github.io

I tried playing around with caps (DOTKAY), etc. (after some Googling around), but didn't help

Hi, you have to enable Travis CI for that repository, too. Go to https://travis-ci.org, login and navigate to 'Acconts'. Then you'll see the list of your repository. Turn on the switch for dotkay/dotkay.github.io, and have a check again.

Ah, thanks. Just did that... Let me build and check...

Ah you're using *.github.io, then the master branch will be used as the source directory of GitHub Pages. But we build the site ourselves, so the result of jekyll build should goes to the master branch. Try change the name of current master branch to other, and make master branch by git checkout --orphan master with an initial commit.

Also you should modify .travis.yml, because of the branch names. Replace master to your source branch, and gh-pages to master.

thanks. trying it now - trying to resolve the travis build errors. should the master and branch have the same set of files?

You only make commits to source branch, then Travis CI pushes generated files to destination branch.

It seems that you switched two branches, you make Travis CI to push to release branch, so the categories/misc directory was generated, but GitHub Pages still using master branch, so jekyll-archives gem is not enabled on the actual site.

so github pages should use the release branch eventually? am confused because travis builds my master properly, but errors out on release :-( but i did the mistake of committing to release branch as well.. have to somehow revert those

let me make the destination as master (in travis.yml) and source as release and see what happens

i finally got around using only master and now the travis builds are going through fine, and it's also generating the categories/misc and i also see the <a tag in the index.html. but it still doesn't show up when published. can you please help me figure out where I am wrong? only when you have time. I think I am close to the solution, but don't know the last mile

To be clear:

  • First, you need two separate branches: master for actual HTML files, and source branch, let's say it source.
  • The content of your current master branch should goes to source. You can just rename the branch and push by git branch -m source, git push origin source.
  • Travis CI will push to master, but you need to create it. Try git checkout --orphan master, git commit --allow-empty -m "Initial commit", git push -f origin master.

Try starting from this .travis.yml:

language: ruby
sudo: false
cache: bundler
rvm:
  - 2.3.3
env:
  global:
    - secure: "..."
before_install:
  - gem update --system
  - gem update --remote bundler
before_script:
  - git config --global user.name "$(git --no-pager show --no-patch --format='%an')"
  - git config --global user.email "$(git --no-pager show --no-patch --format='%ae')"
script:
  - git clone -b master --depth 1 "https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" _site >/dev/null 2>&1
  - rm -rf _site/*
  - bundle exec jekyll build
after_success:
  - cd _site
  - git add -A
  - git commit -m "Updated to $(git rev-parse --short $TRAVIS_COMMIT) at $(date -u +'%Y-%m-%d %H:%M:%S %Z')"
  - git push "https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" master >/dev/null 2>&1
branches:
  only:
    - source

thanks a lot. somehow, i thought i can get through my just having one master branch. let me try this now.

now travis builds fine, it creates categories/misc, etc. but I don't see it getting pushed to the master :-(
(meaning: i dont see _site and sub-directories in the master branch). But the travis build log (attached)
travis_build_log
seems to indicate that it created it. How do I debug further?

I'm not sure, but can you try adding a space between - and secure in your .travis.yml?

wow! adding that one space worked! thank you so much! you're awesome!

Congrats! No problem :)

commented

Thanks yous for the nice theme! Can I know how can I trigger the Travis build after I commit and push my code to master? I added the .travis.yml and committed it with the correct TOKEN, my repo was linked with Travis as well, however no build was triggered on Travis :(

Hi, @neo0907. The .travis.yml has following lines:

branches:
  only:
    - source

But your repository has master branch only. You should push your current master to source branch. The remote master branch is for the generated site content.

  • Rename your local master branch to source with git branch -m source
  • Make new master branch with git checkout --orphan master, git commit --allow-empty -m "Initial commit", git push -f origin master
  • Push your source branch with git checkout source, git push origin source
commented

Thanks for the help! It now failed in Travis with error 128

$ git clone -b master --depth 1 "https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" _site >/dev/null 2>&1
The command "git clone -b master --depth 1 "https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" _site >/dev/null 2>&1" exited with 128.

I am suspecting something wrong with my secure value, I have generate the SECURE token with below code and added. However in my GitHub settings, it says this token has never been used. This doesn't look right, any ideas which part I missed? And in GitHub settings, I did give this token all the access on 'repo' scope.

travis encrypt TOKEN="yourtoken"

screen shot 2018-03-01 at 11 36 25 pm

Oh, your source contains _site directory. This prevents git clone. Add proper .gitignore file to your source branch, and try cleaning with git clean -Xdf. Also I recommend you to clean your master branch, especially files or directories that start with ..

commented

Thanks! It is now working properly 👍