How to save both my _site and jekyll build on github - github

Right now i have the following setup:
My jeyll build is in ~/jekyll-sites
My .git folder is in ~/jekyll-sites/_site
I'm now able to sync the jekyll generated ~/jekyll-sites/_site with my repo at: https://github.com/nielsrasmus/nielsrasmus.github.io
and it works perfect.
But i would also like to to save the whole jekyll build on github.
The question is:
Is it possible to make another repo called: nielsrasmus.github.io-source and sync the whole jekyll build here?
If so, what would be the best way to do it?
I've looked at so many answers that does not quite match what I want. So I'm pretty confused right now :-/

As long as you're not using any Jekyll plugins, you can actually push your Jekyll source to Github, and their servers will automatically generate the _site folder and serve it for you. You won't see this _site directory show up in your repository, but the generated files will be accessible from http://nielsrasmus.github.io
A great reference for how to do this is Tom Preston-Warner's personal blog, which is (naturally) hosted on Github Pages. Note that he placed the _site directory in his .gitgnore file, and Jekyll says "it's probably a good idea" for you to do the same, but you might be able to skip this part.
Both you and Tom are using the User Pages option, so your site gets generated as long as your content is in the Master branch (if you were using Project pages, it would use the gh-pages branch instead).

I think I solved the issue.
I installed the mac version of github and fiddled around, read a lot of man pages and finally I could make it happen :-)
What helped me was to click on the + sign in the bottom of the screen, as shown on the screenshot. Here I could point my repos at a local dir.
nielsrasmus/jekyll-sites: points to the root of the jekyll build.
nielsrasmus/nielsrasmus.github.io: points to the generated site at ~/jekyll-sites/_site

Related

I forked the repo for a Github Pages that I liked, but my fork will not load

I am a total programming noob and assume I'm missing something basic.
I forked this repo: https://github.com/colinmorris/tour-of-heroes
Here is the author's page for that repo: https://colinmorris.github.io/tour-of-heroes/
My fork: https://github.com/SmallFryHero/tour-of-heroes
My page based on that fork: https://smallfryhero.github.io/tour-of-heroes/
My page does not load.
I deployed the Github Pages using the gh-pages branch and from the /root folder.
I imported the code into a different web editor, CodeSandBox, and I can get it to run there along with my changes.
What do I need to fix to get it to run on my Github Pages? I added a readme to get the page to build. It seems to be deployed, but doesn't get past the "loading..." step.
Thanks for any help! Sorry for the total noob question.
The issue is that GitHub Pages, by default, use a static site generator called Jekyll under the hood. It basically converts a set of Markdown files into HTML (and provides templating, themes, plugins, and more).
In the case of your repo, which consists exclusively of static assets, Jekyll doesn't do much, but it does exclude the node_modules directory (see logs), which leads to the scripts in there being unavailable to the deployed page.
To fix this, you can indicate that you wish to skip any Jekyll processing and just upload the files as they are; to do so, add an empty file .nojekyll to the root directory in the gh-pages branch, as described in the documentation.
The repo from which you forked was last deployed multiple years ago, and I suspect the Jekyll default configuration back then didn't exclude node_modules yet.

Very simple HTML resulting in 404 Not Found on GitHub Pages [duplicate]

Here is my GitHub repository on the gh-pages branch.
Everything looks good, I have my index.html, my CSS, JS and pictures folders.
But when I access http://roine.github.com/p1 I get HTTP 404 not found.
Any explanation and solution?
I had just one commit with all my files. I pushed an empty commit, refreshed the page and it worked.
git commit --allow-empty -m "Trigger rebuild"
git push
If this doesn't work, as #Hendrikto pointed out in the comments, check out the Github status page and make sure GitHub Pages are operational.
I did all the tricks on my repo to fix page 404 on Github Page (https://eq19.github.io/) but it kept 404'ing.
Finaly found that my browser hardly keep the 10 minutes cache before it up on the web.
Just add /index.html into the end of URL then it showed up and solved the case.
https://username.github.io/{repoName}/index.html
In my case, I had folders whose names started with _ (like _css and _js), which GH Pages ignores as per Jekyll processing rules. If you don't use Jekyll, the workaround is to place a file named .nojekyll in the root directory. Otherwise, you can remove the underscores from these folders
Four months ago I have contacted the support and they told me it was a problem on their side, they have temporarily fix it (for the current commit).
Today I tried again
I deleted the gh-pages branch on github
git push origin --delete gh-pages
I deleted the gh-pages branch on local
git branch -D gh-pages
I reinitialized git
git init
I recreated the branch on local
git branch gh-pages
I pushed the gh-pages branch to github
git push origin gh-pages
Works fine, I can finally update my files on the page.
If you haven't already, choose a Jekyll theme in your GitHub Pages settings tab. Apparently this is required even if you're not using Jekyll for your Pages site.
I had the same issue after forking a repo with a gh-pages branch. I was able to fix by simply pushing a new commit (just whitespace in index.html) to my fork's gh-pages branch.
In my case on 8/Aug/2017
if your user page is https://github.com/mgravell, you repo name must be
mgravell.github.io
under root, create a file index.html
under root, create a folder docs, create a file
CNAME under docs (note: NO extension like .txt, make sure your file
system shows extension)
gh-pages branch is optional, master branch is sufficient
more: check official docs here: https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/
Just wait about ten minutes to one hour. If it still doesn't work, contact github. Usually it's the problem at their end.
But, if you're in a hurry, you can try to open by adding "?" question mark at the end of URL. It force query to search for the resource. Like this:
http://roine.github.com/p1?
In my case the browser had a previous cached version of my app. To avoid getting the cached version, access you url using a random query string:
https://{{your-username}}.github.io/{{your-repository}}?randomquery
My pages also kept 404'ing. Contacted support, and they pointed out that the url is case sensitive; solved my issue.
in my case i had to go to project settings and enable the github pages. The default is off
If you saw 404 even everything looks right, try switching https/http.
The original question has the url wrong, usually you can check repo settings and found the correct url for generated site.
However I have everything set up correctly, and the setting page said it's published, then I still saw 404.
Thanks for the comment of #Rohit Suthar (though that comment was to use https), I changed the url to http and it worked, then https worked too.
Add the following in the beginning of the index.html file
<!DOCTYPE html>
In my case in react was necessary to select the gh-pages branch:
I was facing the same issue, after trying most of the methods mentioned above I couldn't get the solution. In my case the issue of because of Github changing the name of master to main branch.
Go to Setting -> go to GitHub Pages section and change the branch to main:
to
Save it and select a theme, and the website is live.
If you are sure that your structure is correct, just push an empty commit or update the index.html file with some space, it works!
I had this exact problem with typedocs. The README.md worked but none of the actual docs generated by my doc strings displayed, I just got a 404 Github Pages screen.
To fix this, just place a empty file in your /docs directory (or wherever you generate your docs) & call it .nojekyll
To confirm, your file structure should now look like:
./docs/.nojekyll # plus all your generated docs
Push this up to your remote Github repo and your links etc should work now.
Also make sure you have selected in your Github settings:
Settings -> Github Pages -> Source -> master brach /docs folder
Depending on your doc framework, you probably have to recreate this file each time you update your docs, this is an example of using typedocs & creating the .nojekyll file each time in a package.json file:
# package.json
"scripts": {
"typedoc": "typedoc --out docs src && touch docs/.nojekyll"
},
The solution for me was to set right the homepage in package.json.
My project name is monsters-rolodex and I am publishing from console gh-pages -d build.
"homepage": "https://github.com/monsters-rolodex",
The project was built assuming it is hosted at /monsters-rolodex/.
Before it didn't work because in the homepage url I included my github username.
I got the site to work by deleting the "username.github.io" folder on my computer going through the steps again, including changing the index/html file.
My mistake (I think) is that i initially cloned "https://github.com/username/username.github.io.git" instead of https://github.com/username/username.github.io (no ".git")
In my case, all the suggestions above were correct. I had most pages working except few that were returning 404 even though the markdown files are there and they seemed correct. Here is what fixed it for me on these pages:
On one page, there were a few special characters that are not part of UTF-8 and I think that's why GitHub pages was not able to render them. Updating/removing these char and pushing a new commit fixed it.
On another page, I found that there were apostrophes ' surrounding the title, I removed them and the page content started showing fine
Another variant of this error:
I set up my first Github page after a tutorial but gave the file readme.md a - from my perspective - more meaningful name: welcome.md.
That was a fatal mistake:
We’ll use your README file as the site’s index if you don’t have an
index.md (or index.html), not dissimilar from when you browse to a
repository on GitHub.
from Publishing with GitHub Pages, now as easy as 1, 2, 3
I was then able to access my website page using the published at link specified under Repository / Settings / GitHub Pages followed by welcome.html or shorter welcome.
For some reason, the deployment of the GitHub pages stopped working today (2020-may-05). Previously I did not have any html, only md files. I tried to create an index.html and it published the page immediately. After removal of index.html, the publication keeps working.
I was following this YT video. So, when I ran the command in my terminal, it pushed the code to gh-pages branch already. Then I pushed to the master branch. It was giving me 404 error.
Then I swapped the branch to master and then again reverted to gh-pages and now the error is gone. It's pointing to the index.html even if it's not in the URL.
I bound my domain before this problem appeared. I committed and pushed the branch gh-pages and it solved my problem. New commits force jekyll to rebuild your pages.
In my case, the URL was quite long. So, I guess there is a limit. I put it to my custom subdomain and it worked.
On a private repo, when I first added and pushed my gh-pages branch to github, the settings for github pages automatically changed to indicate that the gh-pages branch would be published, but there no green or blue bar with the github.io url and no custom domain options.
It wasn't until I switched the source to master and quickly switched the source back to gh-pages that it actually updated with the green bar that contains the published url.
Your GitHub Pages is available at http://roine.github.io/p1 instead of http://roine.github.com/p1.
By the way, you can fix your project's description.
In my case it was that I had recently set up a custom domain for GitHub pages, but GitHub had forgotten my custom domain under (repo)<name>.github.io / Settings / Pages.
I added the custom domain again and then it immediately started working.
Go to settings section of your repository and choose master branch at the Source section and click save button after that refresh the page and you will be able to see the link of your page!.
I faced this problem (404) too and the root cause was my file was named INDEX.md. I was developing on Windows and my local Jekyll site worked (since Windows treats file names case insensitive by default). When pushed to Github, it didn't work. Once I renamed the INDEX.md to index.md, things worked well.

Why put the _site-directory of a Jekyll site in .gitignore?

The documentation of Jekyll tells me, that the _site-directory of a Jekyll site contains the compiled version of the site I have created after running
Jekyll build
Several articles recommend, that I include the _site-directory in my .gitignore-file because "it just contains the compiled version of my site". (that's what some articles recommend. So, I am not sure if I don't understand some concept of Jekyll or some concept of Git.
If the _site-directory contains the compiled version of a site, shouldn't that be the thing that is on the server the provides the final website? I do understand why you put source code on github and what to do with it, but in the case of github pages, Github is not a versioning system but a file hosting system and the file hosting system should host compiled versions of my work to provide it via MyUsername.github.io to users, right?
My question is: shouldn't it be only the _site-directory of my Jekyll website that I deploy to Github because that should be the compiled source code that github provides to users? So, shouldn't I put anything else in the .gitignore-file EXCEPT the _site-directory?
If I got this all wrong: what is the point in compiling my website via
Jekyll build
if I don't use the compiled source code for anything?
Two solutions :
You don't use Jekyll plugins (or only those supported by github pages)
You build your site only if you need to test it locally (jekyll build or jekyll serve). The generated code (in _site) will not be versioned as github pages will generate pages from the sources.
Put _site to .gitignore
Push you sources to github pages
You use Jekyll plugins
In this case, you need to build locally because Github pages cannot do the job with plugins.
Jekyll build locally
Put _site to .gitignore
commit your sources in one branch
commit your _site in another branch
See this post for more explanations.
I think the point where you are confused is that most of the tutorials talk about at least two different repositories.
the source code of your site, this is where you call Jekyll build
the compiled result, this is the one where you put the contents of the _site directory
Then it makes sense to ignore _site in case 1. out of the same reason you normally ignore compilation results: they are not meant to be tracked because they might change between every compilation without changing the source, so you would have to commit after every build although nothing (visible) has changed.
For repository 2. you of course have to update it with the contents of _site from repository 1 after your build.
Having said that you can of course combine 1. and 2. into a single repository by using master for the contents of _site and another branch e.g. source for the project with the Jekyll build files, here ignoring _site and then updating the master branch with the contents of it after changes.
the _site folder is cleared and all files inside are re-generated upon each "jekyll build". tracking a file that is to be removed seems to serve no useful purposes.
if you are thinking to git push your jekyll site to your github repo as a project page (gh-pages), the _site folder again serves no purposes as the jekyll installation at github will generate the _site for you automatically upon your files upload (git push).
the _site folder is useful only for local preview of your jekyll site (typically to be found at localhost:4000 by default).
I believe you might be looking at things the wrong way, It makes sense to ignore _site since every time you jekyll build your _site gets blasted, everything in there gets erased and written again.
So in my own opinion what you would like to push to github is the working directory since it's there where you work and all your changes are being versioned... with the plus of github doing the compiling and automatically building the site.
That being said, I usually keep _site out of my gitignore since I deploy to another hosting service and my deployment framework grabs the github repository and deploys from a particular branch I need the _site to be there.

jekyll and github - how to update the blog post?

Good day.
Could you help me with a little problem I am experiencing.
I have a jekyll blog on the github. The problem is after I updated my old post, committed and pushed it, the blog post doesn't show any changes, but I see that the commit has been pushed successfully.
If I run jekyll --server locally, it shows updated blog post and it doesn't report any errors.
I have no jekyll plugins installed.
What am I doing wrong or misunderstanding? Thanks a lot.
Added by Nawaz:
I'm facing exactly same problem. My I pushed added one markdown post and few css, and modified layouts and includes, then I pushed them to github. It is done successfully. My github is showing all the changes in the repository, but the github blog (i.e the generated html posts out of markdown) are still same. No change to them at all. It is showing some posts which doesn't even exist in the repository. But when I do jekyll --server locally, then every update is being shown on my (local) blog hosted at http://localhost:4000.
Please help me!
If your Jekyll site is not rendering properly after you push it to GitHub, it's useful to run Jekyll locally so you can see any parsing errors. In order to do this, you'll want to use the same version that we use.
GitHub's Pages servers currently use Jekyll 0.11.0 with Liquid 2.2.2, and run it using this command:
$ jekyll --pygments --safe
More info
I'm now trying to solve the problems with my pygments highlighting (works locally, doesn't show on github at all, even though I'm receiving mails about succesful build). Findings so far:
Make sure that youre repository' default branch is 'master' (go to your repository Admin page).
Put your Jekyll source files in some other branch, and put the _site content to your master branch. There will be no _config.yml, no YAML front matter so github will render your stuff as is, and you would be building it locally on that other branch. This actually worked for me. It requires some manual labour when moving _site from that other branch to your master, but I'm fine with that - at least I do not have to rely on github build process which seems to be a bit buggy, plus, I can have whatever plugins I wish.
When ever you generate your jekyll site locally for testing, always run jekyll --no-auto --server. This would display if there were any errors encountered during the generation of your site. Also, before generating your site delete _site directory and then run the command as described above.
Let me know if you see any errors as such. We can debug further

Jekyll plugin not working

I have developed a simple Jekyll plugin, to generate the categories pages. IT works fine on my local system but does not work on github site.
Here is the source of the plugin:
https://github.com/madhur/madhur.github.com/blob/master/_plugins/site_process.rb
It should generate a page such as this:
http://www.madhur.co.in/categories/Security.html
However its not generated. Any ideas?
GitHub doesn't allow Jekyll plugins, turns out we don't want you running arbitrary code on our servers :)
I think this answer from Andión is better.
You can just upload the contents of the _site folder. That way you will simply push the static site. A simple way of doing that would be moving your .git/ folder to the _site folder, committing and pushing those changes. After that you will generate your site as usual and then push the changes to github from the _site folder. – Andión