11ty / eleventy-base-blog

A starter repository for a blog web site using the Eleventy static site generator.
https://demo-base-blog.11ty.dev/
MIT License
1.25k stars 617 forks source link

Doesn't work with user pages and organization pages. #11

Closed mohsenkhanpour closed 6 years ago

mohsenkhanpour commented 6 years ago

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:

Your site is having problems building: The tag set on line 14 in feed/feed.njk is not a recognized Liquid tag. For more information, see https://help.github.com/articles/page-build-failed-unknown-tag-error/.

Travis publishes the deployment to gh-pages branch, whereas organization pages use master branch. Any thoughts?

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

zachleat commented 6 years ago

The travis logs for this are here, if that helps: https://travis-ci.org/11ty/eleventy-base-blog

zachleat commented 6 years ago

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

mohsenkhanpour commented 6 years ago

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.

mohsenkhanpour commented 6 years ago

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

mohsenkhanpour commented 6 years ago

@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.
mohsenkhanpour commented 6 years ago

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

joewiz commented 4 years ago

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