How to publish a Ionic 5 website on GitHub pages? - github

I already had published some website on GitHub pages with no issue. My common workflow is to build a website, upload in the root (/) or docs (/docs) directory of my repository and set up GitHub Pages in the settings.
This is my first time using Ionic. I wrote a website and I build it by running ionic build --prod.
Than I uploaded my contents to the /docs directory of the repo.
When I visit the website https://<nickname>.github.io/<myrepo>/ it leaves me in a blank page. Inspecting with Google Chrome dev tools, I can see that scripts are referred to https://<nickname>.github.io/script.js instead of https://<nickname>.github.io/<myrepo>/script.js
How can I make it work? What I am doing wrong?
You can find the full source code of my project here. You can build it by yourself and try if there is something wrong. The site is functional when I execute it on my local web server for testing.

How to make any React website work with GitHub Pages
Prerequisites
npm installed
directory containing the React project
git repository set on this directory and linked to the remote on GitHub
Steps to follow
Run npm install gh-pages --save-dev
Edit the package.json file:
Add this line: "homepage": "http://githubname.github.io/repository". Use your nickname and repository name
Add these lines in the scripts section:
"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
Push a commit
git add .
git commit -m "Create a React app and publish it to GitHub Pages"
git push origin master
Your website is available at http://githubname.github.io/repository
For more info see this page
Additional steps for Ionic 5
If you are using Ionic 5, some errors can still occur.
In this case, visit the website on http://githubname.github.io/repository and open the Chrome Inspector Tools (CTRL + SHIFT + I).
Look at the Console: some JS or TS script could be not loaded. You can see that the browser is looking at the scripts in a wrong path.
By manually editing the index.html you can point the script to the right URLs.
Upload the edited index.html in the gh-pages branch of your GitHub repo and you are good to go.

Related

Jekyll can't find layout

I am using git page to make a github website. I am using academicpages/academicpages.github.io. I forked this repo to my gitpage repo, and edited the pages in the /_pages folder. But when I build the site with jekyll, I get the following:
Jekyll Feed: Generating feed for posts
Build Warning: Layout 'single' requested in pages/about.md does not exist.
Build Warning: Layout 'archive' requested in pages/dissertation.md does not exist.
Build Warning: Layout 'archive' requested in pages/research.md does not exist.
Build Warning: Layout 'archive' requested in pages/software does not exist.
Build Warning: Layout 'archive' requested in pages/teaching.md does not exist.
I am not following this because, in the git repo I made I have the layouts in the _layouts folder. archive.html and single.html are all in there.
Then what could be causing the problem?
One question though would be, should I have all these files in the git website folder on my hard drive? Since I forked the theme repo, the files are all on my git repo, and I don't have the layout files on my hard drive.
From the documentation within https://github.com/academicpages/academicpages.github.io
To run locally (not on GitHub Pages, to serve on your own computer)
Clone the repository and made updates as detailed above
Make sure you have ruby-dev, bundler, and nodejs installed: sudo apt install ruby-dev ruby-bundler nodejs
Run bundle clean to clean up the directory (no need to run --force)
Run bundle install to install ruby dependencies. If you get errors, delete Gemfile.lock and try again.
Run bundle exec jekyll liveserve to generate the HTML and serve it from localhost:4000 the local server will automatically rebuild and refresh the pages on change.
So, yes, basically you clone the repo to have all files on your harddisk, then dependencies are installed and finally you start your site locally using jekyll serve or jekyll serve -i.

deploy react app on github gh-pages

when I'm trying to deploy react app on gh-pages it gives me this error
I could not deploy my react app on gh-pages github because I was using windows. on Ubuntu works fine.
Another alternative (whilst not as nice as being able to run npm run deploy is to manually add the build folder to a git repository and then set up GitHub pages via the website in Settings -> GitHub Pages

Using ReadTheDocs to host Sphinx Docs created with Jupyter

I continue to have failed builds with ReadTheDocs using a github repository with Jupyter notebooks rendered using sphinx and the readthedocs theme. I am able to render these locally, however when I try with RTD, I get the following fail message:
I tried placing the nbsphinx.py file in the repository but things still fail. Link to RTD is here:
https://readthedocs.org/projects/calculus-notes/
Github repo is here:
https://github.com/jfkoehler/calc_docs
RTD needs to install nbsphinx. To tell RTD to install packages, you must:
From RTD FAQ, My project isn’t building with autodoc:
enable the virtualenv feature in the Admin page of your project, which will install your project into a virtualenv, and allow you to specify a requirements.txt file for your project.
Create requirements.txt in your repo and add nbsphinx to its contents. See https://github.com/spatialaudio/nbsphinx/blob/0.2.14/doc/requirements.txt#L2
After you commit and push item 2 to your repo, then RTD should install nbsphinx and be able to build your docs successfully, or at least proceed to the next failure if there is one.

Github Pages No Longer Builds

I have a working github pages blog here. -See update below- After adding a new blog post and pushing the update, I received an email from github indicating "Page Build Failure". I can successfully build and serve the site using jekyll locally without issue.
After 22 attempted fixes and subsequent gh build failures, I am at a loss. The base of my blog is built of off this, and I have cloned a fresh copy into my personal blog in an attempt to build fresh from this template. I now get the same build error when pushing this clean template directory.
The only info the github email gives is:
"The page build failed with the following error:
Page build failed"
Has something changed on githubs side that breaks the linked template? Is anyone able to get github to successfully build that template now? I have been successfully updating this blog as recently as August 12th, has something changed in the past couple weeks that has broken my site?
The repo for the site is here
Any help would be greatly appreciated.
-pH+
Update: I attempted to start completely fresh by deleting the working site and following the steps of the template instructions, without success, so the above link will now give a 404 site not found error.
I was unable to figure out why github pages suddenly was unable to build this template, but I've found a work around by compiling the page locally and pushing that to github. This article provides a step by step guides on how to publish to github pages using this technique.
Essentially you need to locally compile and push using the following script in the local Rakefile:
require "rubygems"
require "tmpdir"
require "bundler/setup"
require "jekyll"
# Change your GitHub reponame
GITHUB_REPONAME = "ixti/ixti.github.com"
desc "Generate blog files"
task :generate do
Jekyll::Site.new(Jekyll.configuration({
"source" => ".",
"destination" => "_site"
})).process
end
desc "Generate and publish blog to gh-pages"
task :publish => [:generate] do
Dir.mktmpdir do |tmp|
cp_r "_site/.", tmp
pwd = Dir.pwd
Dir.chdir tmp
system "git init"
system "git add ."
message = "Site updated at #{Time.now.utc}"
system "git commit -m #{message.inspect}"
system "git remote add origin git#github.com:#{GITHUB_REPONAME}.git"
system "git push origin master --force"
Dir.chdir pwd
end
end

how to serve my own gitbook using github pages

I've created my own gitbook. looks good locally.
but how shall I integrate it into my github pages? Similar issues here difficulty-in-getting-gitbook-site-to-show-up-in-github-page
I tried that approach as well, but I have problem setting the grunt up, and I also I would like to do that myself before using an integrated tool.
I tried to copy the generated _book folder to my github page folder, but that didn't workout as there are some encoding issues
Similar question here
I had this question because I don't understand github pages, the underlying steps involve
build the _book folder, this is the static content that will be served
create gh-pages branch copy the _book folder content into gh-pages
github will then serve the content
the command gitbook publish will finish all 3 steps. but I am not familiar with grunt as well , as npm install . is a pre-step.