Why can't I host my project on github pages? - github

I have a simple weather app using react I've built and pushed to Github. Everything works when I run it locally but when I try to host it on Github pages, I get a 404 error.
https://caseycling.github.io/weather-app/
I'm not sure what I did wrong as I took the same steps as with every other project I've succesfully deployed: went to settings and under Github pages, I chose master branch as the source. Initially, it was just displaying the readme but now it only displays a 404 error message. When I've googled this issue, some people are saying I need to move my folders to the root of the directory but I'm not sure how to do that exactly.
Here is the repo:
https://github.com/caseycling/weather-app/

My understanding is that in order to run a react app in github pages you need to setup the gh-pages plugin and have a special 'deploy' build script in package.json
https://itnext.io/so-you-want-to-host-your-single-age-react-app-on-github-pages-a826ab01e48
https://codeburst.io/deploy-react-to-github-pages-to-create-an-amazing-website-42d8b09cd4d
https://medium.com/the-andela-way/how-to-deploy-your-react-application-to-github-pages-in-less-than-5-minutes-8c5f665a2d2a
There are also apparently certain restrictions in what you can do with the router in github pages websites, but for a simple app it should be sufficient.

Related

Using Github to create a webpage but it returns a 404 error

Am trying to test out hosting a website from Github using Github pages.I created a skeleton website using Jekyll and uploaded it into a .github.io repository:
https://github.com/themallardcomplexion/themallardcomplexion.github.io
I then enabled github pages from the setting.
So right now if I go to: themallardcomplexion.github.io I should be able to see the Jekyll site. However all I get is a 404 error...
I know its not an index issue as I have an index.md file in my repository. I've enabled github pages so what am I doing wrong? I have tried searching for the problem online but none of the solutions seem applicable..
Thanks internet people
I deleted everything and created a new repository. Seems to be working now. Dont know what the problem was but at least its working..

GitHub Pages 404 when trying to host Polymer Starter Kit

So I'm simply trying to host the polymer-starter-kit on git pages which should be easy enough in theory there's already a simple tutorial for how to do so here. The problem is after following all the instructions and navigating to my SKHolmes.github.io I get a 404 from github saying it couldn't load the resources, be that one or many. I can clearly see there is an index.html file in the root directory.
Here is the error
Here is my repository
Has anyone had a similar problem? Is there any tricks I'm missing?
Did you read the gh-pages doc? When you want username.gitub.io you need to push to the ´master´ branch, not the 'gh-pages' branch.

Not able to see the webpage of the github repository

I am very new to github.
I pushed my repository into github.
And in settings page, they tell my site is published at
http://jerinzam.github.io/coi-site.
But that URL gives me a 404 page.
Can someone give some xplanation on this.
And also FYI my project uses MEAN stack
Thanks in advance
You have two problems:
GitHub won't run your site. It is only for static hosting, not Node.js hosting. It also doesn't support any databases, including MongoDB.
From the project pages documentation:
The gh-pages branch is used to build and publish Project Pages sites.
You have three branches, but none of them are called gh-pages:
gh-pa
gn-pages
master
This is exactly as above.
You can host your code repo on github, but the web link to that repo will literally be whatever it is in the browser.
Now if you are wanting to run your site, then try this - https://masteringmean.com/lessons/557-Setup-and-Getting-Started-Running-Your-Site
You will need to have the mongo server running before starting the server. Check this is running by typing $mongod
so just go to the directory then type $ node run.js

GitHub pages are not updating

I'm running into a weird issue with GitHub pages. I pushed a new commit to my personal pages page maltzj.github.io, but the new article isn't showing up there. When I execute the server locally, a post lives at localhost:4000/posts/the-price-of-inconsistent-code/. However, when I go to http://maltzj.github.io/posts/the-price-of-inconsistent-code I get a 404. I also added a new file which should live at http://maltz.github.io/test.html, but that also throws a 404.
Everything builds and runs locally. My Git repository is up to date, and there is nothing on the GitHub status page about problems with builds, so I'm at a little bit of a loss about where to go with this. How can I get my page to update with new content that I add?
For reference, the location of the repository which backs my page is http://github.com/maltzj/maltzj.github.io
None of these solutions solved it for me. The solution was to edit the index.html file in the GitHub website.
The website then updates on the web as expected.
Go to your index.html file through your site (example.github.io/index.html) and then reload the page. Then you can go back to (example.github.io) and it should have updated. You can do the same with the master.css file, etc.
If it doesn't work, try reloading (github.com/example/example.github.io/[blob/master/]index.html) instead and it will have updated.
For others, also check the dates of your posts. I just had this problem. I'm at UTC+11 and I'm pretty sure the server is at UTC. Thus if I date my posts with my local time, the server thinks they are in the future and won't build them. Using UTC avoided this for me.
As mentioned by joao cenoura in the comments below:
you can tell jekyll to show "future" posts by adding future: true to your _config.yml
and/or add timezone: TIMEZONE to specify your timezone.
See https://jekyllrb.com/docs/configuration/ for more info.
I had an empty CNAME file. Check that if you're having a similar issue.
I had this fault today with a static page - the cause was actually a service failure at GitHub Pages itself. You can check for service messages at https://www.githubstatus.com/.
I had the problem of having an unverified email. The update worked for the first time, but it failed after that. A verified email is needed to trigger a GitHub pages build. Also a deploy key cannot be used for this, as it won't trigger a build.
Source: http://web.archive.org/web/20140712011932/https://help.github.com/articles/troubleshooting-github-pages-build-failures/
Disclaimer: this was the case in 2014. Don't know if it's still required.
I had an unclosed <a> tag which caused the build to be pending forever. Fixing that solved the issue.
It makes sense that GitHub would verify your links.
I got it to work.
Mine was a simple problem. It was a browser cache problem.
I opened my link on a different browser and it showed me the updated push.
In my case, none of above solutions works. Finally I find out the reason is: there is "relative_permalinks" option in my _config.yml. This option is recently deprecated in Jekyll 3.0.
Refer to:
https://help.github.com/articles/removing-relative-permalinks/
I know this might sound simple, but make certain you are on the right branch and in the right file.
In my case, I made a GitHub page and tried to commit from my local repository on the master branch. Also, I was updating my filename instead of index.html. These were my errors. I had to switch to the GitHub page branch and update in the index.html commit, push and then everything worked fine.
For me, I just waited ~5 minutes, and it was updated.
If someone has made the branch gh-pages from scratch (manually) the problem is that you need a file call params.json to make it work.
I don't have this params.json file, but it still works...
In my case, it happened to be that I mentioned a relative path to refer to an image, something like - ./test.png.
It seems that it's not allowed, and it may be a security issue or what. Whatever, if you've done something like that, remove it and refer to it as test.png.
In my case the problem was because of my repository was private. After I made it public, the problem has gone.
The weird part of story is that I was able to create private repository and use GitHub pages with it. I did it in accordance with the official guide (http://take.ms/p2SS7). It worked fine for about 9 commits, but on the 10-th it became broken.
I ran into the same mysterious issue today. I pushed some new code to my github.io-repository, but the changes did not show up on the corresponding webpage. I inspected the page and did not see the new code in the source. I solved the issue by doing a hard reload. On Chrome, you can do a hard reload by opening up Dev Tools and right-clicking on the refresh-button and choosing Hard Reload.
Please refer to the Jekyll troubleshooting website, as there are multiple error sources: Troubleshooting Jekyll build errors for GitHub Pages sites
In my case a German umlaut ("ö") in a Markdown file caused the problem.
In my case, I forgot to define kramdown in _config.yaml
# Build settings
markdown: kramdown
This was caused when I was converting from a theme without to a theme with the kramdown requirement.
Make sure your run
npm run deploy
Clear your browser cache.
In my case, after trial and error on some solutions here, what fixed it was adding the encoding to the _config file like this
encoding: UTF-8
More troubleshooting options here
For me it was an issue with not properly having a .gitmodules file.
I was able to troubleshoot in the settings tab of my repository, under the GitHub pages section, which indicates build issues and was helpful for troubleshooting.
Oddly (and simply) enough I created a new branch, made that branch the "default" branch and pushed from there.
This worked for me.
My GitHub Pages was turned off under the Settings tab of the repository.
I don't remember turning it off, but there it was, and turning it back on was the fix.
In the repository settings, make sure the GitHub Pages is currently being built from the gh-pages branch.
In my case, my problem was after git push my GitHub file was updating but not showing my website on GitHub pages.
Note: I was creating Website by React
Also, on the HTML project, I faced the same problem. In that case, I just did first of all git pull and then git status | git add . | git commit -m"adding some content" | and git push. It worked for me.
But in the React project, it didn't work. I run this again on my cmd npm run deploy then my React web application is showing on GitHub pages.
My suggestion is to try everything showing on this post comments. Because the solution to this problem is not one.
In my case I left an empty parameter, url, in _config.yaml.
After I've specified url: example.github.io everything started to work.
I had this problem this week and no solution worked.
I don't use Jekyll, only pure static HTML.
It just sat three days refusing to update.
Here is what I had to do to get it to publish again.
Make a snapshot branch from master.
Reset the master branch to the last commit that is live. (Commits tab, green checkmarks indicate published commits)
Make a new commit with a smoke test. I made an HTML comment I could grep.
Force push master.
Check results curl https://example.com | grep SMOKETEST
Reset master again, removing the smoke test.
Cherry-pick each commit from the snapshot branch you need to get your unpublished changes back into master (cherry-picking gives the commits new ids/hashes, avoiding the risk of anything having cached them from before).
Force push master again.
Now you should get green checkmarks and published updates.
Note: It could be enough to force push to remove the commits that are stuck and getting them back again. The smoke test is almost certainly not required. Cherry-picking may not be required.
Github doesn't publish to github pages for me if I edit and commit files directly on github web site.
However, if I edit file locally and commit with GitHub Desktop, then change is published to site within seconds.
BTW, my email is verified, so this shouldn't be an issue. And I'm using same account.
Solution worked for me for an app created using create-react-app :
Go to GitHub Pages section under repository settings
Change source from gh-pages branch to master branch
Wait and check your custom domain website, should show master branch README.md file
Now change the source back to gh-pages
Wait couple minutes, now latest changes reflected on custom domain website
I had tried different solutions, none worked. Like a new commit, an empty commit, browser cache clear, wait for 5 - 10 minutes, delete gh-pages branch and push again, edit CNAME, create a new CNAME under on master branch etc
Note: My app has no _config.yaml file, no jekyll. I'm using custom domain with https (google domains). gh-page branch auto created by package.json script deploy: "gh-pages -d deploy"
In my case, I had made a couple of changes in the index.html and style.css files but those changes were not reflecting on the Github pages. But when I updated the Readme file by adding one line the Page got updated.
Maybe you can try this, as it might work for you just like it did for me.
If you are deploying some simple HTML codes, try this:
First, go to Actions > Deploy static content to Page:
Then, click the Run workflow:
My site failed to deploy today because of a transient failure in the GitHub Pages deploy actions. The action needed to be re-run through the Actions tab for the new version of my site to appear.
The story:
I pushed new content, on a site that's purely static and doesn't use Jekyll. After many fruitless Shift-Ctrl-R reloads on Chrome, I decided to investigate. I first visited Settings→Pages for the site’s repository, and saw that no recent deploy had taken place.
Why not, I wondered? After double-checking that my push had really gone through, I clicked the word “deployed”, and was taken to a GitHub Action that had failed!
Since the error message ECONNRESET looked like a generic network error internal to GitHub’s network, and not any problem with my site, I clicked the “Re-run” button in the upper right and asked GitHub Actions to re-run the failed task. Within a few seconds it had been re-tried and had succeeded!
Lessons:
Deploys are vulnerable to transient errors.
Deploys these days happen as normal GitHub Actions that you can inspect.
The deploys can be re-tried.

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