yous / whiteglass

Minimal, responsive Jekyll theme for hackers
https://yous.github.io/whiteglass/
MIT License
725 stars 197 forks source link

regarding post categories #13

Closed dotkay closed 7 years ago

dotkay commented 7 years ago

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,

yous commented 7 years ago

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.

dotkay commented 7 years ago

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

yous commented 7 years ago

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.

dotkay commented 7 years ago

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

yous commented 7 years ago

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.

dotkay commented 7 years ago

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

yous commented 7 years ago

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

yous commented 7 years ago

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.

dotkay commented 7 years ago

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

dotkay commented 7 years ago

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

dotkay commented 7 years ago

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

yous commented 7 years ago

To be clear:

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
dotkay commented 7 years ago

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

dotkay commented 7 years ago

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?

yous commented 7 years ago

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

dotkay commented 7 years ago

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

yous commented 7 years ago

Congrats! No problem :)

zhaooyue commented 6 years ago

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 :(

yous commented 6 years ago

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.

dotkay commented 6 years ago

You can refer to mine. I push it to source.

On Wed, 28 Feb 2018 09:44 Chayoung You, notifications@github.com wrote:

Hi, @neo0907 https://github.com/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

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/yous/whiteglass/issues/13#issuecomment-369320856, or mute the thread https://github.com/notifications/unsubscribe-auth/AM5aDkM7totTIjwkJi9peNonK5CjBlw8ks5tZZAUgaJpZM4O0Vft .

zhaooyue commented 6 years ago

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
yous commented 6 years ago

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 ..

zhaooyue commented 6 years ago

Thanks! It is now working properly 👍