Closed mohsenkhanpour closed 6 years ago
Huh—interesting!
I do have this setup for the eleventy-base-blog project.
https://11ty.github.io/eleventy-base-blog/ using the following .travis.yml: https://github.com/11ty/eleventy-base-blog/blob/master/.travis.yml
Discussion and instructions for this are in #2.
The travis logs for this are here, if that helps: https://travis-ci.org/11ty/eleventy-base-blog
Looking at my setup it looks like it triggers on commits to master
but actually deploys the output to gh-pages
(any liquid templates that might be consumed by Jekyll have already been processed at this point.)
You can see evidence of that here: https://github.com/11ty/eleventy-base-blog/tree/gh-pages
Yes, I am able to run eleventy on gh-pages for projects. Because you can set the active branch for gh-pages to "master", "gh-pages", "docs" or you can even disable it.
According to your deployment we can see that it is a project page not a user or organization page. (More info)
I was able to deploy with Travis CI, my logs here, however when checking the build status for pages it gives me two statuses: One for Github Pages which fails and one for Travis which succeeds. In the end when I load the entry page I get a 404.
For organization and user pages, the branch is locked to master and Travis pushes to gh-pages.
Has anyone had any luck deploying to a user/organization repo? For example: 11ty.github.io (which is a user page) and not: 11ty.github.io/eleventy-base-blog/ (which is a project page)
Thanks for comments.
@zachleat I guess we should be able to tell Github Pages to avoid treating the repo like a Jekyll website by adding a .nojekyll
file to the root.
However we still have to tell Travis to build into master
branch as user/organization pages are read from the master
branch.
@zachleat In order to tell Travis to deploy to master
branch you should put your 11ty source in a branch other than master
like 11ty
. Then you configure Travis to listen to changes on 11ty
branch and configure target branch to master
. All in all .travis.yml
should look something like this:
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep-history: true
on:
branch: 11ty
target-branch: master # Default for this value is gh-pages, but user/organization pages are read from master so we have to add this field.
@zachleat We can close this issue. But I guess there should be a kind of documentation in README.md
for people who want to use 11ty and Github Pages for their user/organization pages.
Many thanks to @mohsenkhanpour for the workaround above! I just wanted to report a slight typo: the key is not target-branch
but target_branch
(underscore, not hyphen; see https://docs.travis-ci.com/user/deployment/pages/#further-configuration). This suggestion was the breakthrough that allowed me to switch from an old vanilla GitHub Pages setup to 11ty + Travis CI.
The other useful suggestions I found were: since I am using a custom domain, the fqdn
field (see "Custom Domain" in https://snook.ca/archives/servers/deploying-11ty-to-gh-pages). I also found the troubleshooting suggestions under "Token Errors" at https://www.freecodecamp.org/news/learn-how-to-automate-deployment-on-github-pages-with-travis-ci/#token-errors useful.
Here's my .travis.yml
file: https://github.com/joewiz/joewiz.github.io/blob/11ty/.travis.yml#L15
I deployed the starter blog for my organization page with Travis CI. But as organization pages are formatted like: organization.github.io, it automatically thinks this is a Jekyll build. I get the following error:
Travis publishes the deployment to gh-pages branch, whereas organization pages use master branch. Any thoughts?