top of page

Add Your Demo Content On GitHub Pages: How to Showcase Your Projects Online

  • settwalltentoula
  • Aug 18, 2023
  • 6 min read


GitHub Pages are public webpages hosted and published through GitHub. The quickest way to get up and running is by using the Jekyll Theme Chooser to load a pre-made theme. You can then modify your GitHub Pages' content and style.




Add Your Demo Content On GitHub Pages




The main types of content for Jekyll sites are pages and posts. A page is for standalone content that isn't associated with a specific date, such as an "About" page. The default Jekyll site contains a file called about.md, which renders as a page on your site at YOUR-SITE-URL/about. You can edit the contents of that file to personalize your "About" page, and you can use the "About" page as a template to create new pages. For more information, see "Pages" in the Jekyll documentation.


Your theme includes default layouts, includes, and stylesheets that will automatically be applied to new pages and posts on your site, but you can override any of these defaults. For more information, see "About GitHub Pages and Jekyll."


If you have more than one email address associated with your account on GitHub.com, click the email address drop-down menu and select the email address to use as the Git author email address. Only verified email addresses appear in this drop-down menu. If you enabled email address privacy, then @users.noreply.github.com is the default commit author email address. For more information, see "Setting your commit email address."


In this demo, we are using the gh-pages branch to publish the website. You can use other sources if you find them more appropriate. For example, I am publishing the web version of this GitHub-Pages-Demo repository using the master branch, and GitHub renders this README.md file and show it as a web page.


You can add and update the default notebooks and files by clicking on the contentsdirectory and dragging notebooks from your desktop onto the contents listing. Wait forthe files to be uploaded and then save them (commit them) to the main branch of therepository.


There are quite a bit of manual steps involved and switching to your gh-pages branch to recompile a static version of your project can be painful if you have staged and unstaged changes in your repository.


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 -price-of-inconsistent-code I get a 404. I also added a new file which should live at , but that also throws a 404.


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.


Now that your source code has been pushed to GitHub, you'll need to create a GitHub Actions Workflow that builds your project, commits the output and pushes the code to a separate GitHub branch. GitHub Pages will use this separate branch (usually named 'gh-pages') as the static files for your site.


Clicking that link will take you to the 'Edit new file' page. The file that you are about to create will instruct GitHub Actions how to build and deploy your project using YAML.These Workflow YAML files will be stored under the folder '.github/workflows/'.


Now, you must configure your jobs, and which image each job will run on. Give your job a meaningful name following the kebab-case naming convention such as deploy-to-github-pages.Configure your job to run on Ubuntu by adding runs-on: ubuntu-latest, and add an empty steps property.


Now that you have successfully published the project to the 'release' folder, you can use another very helpful action from the marketplace called 'github-pages-deploy-action'. This action will make it easy to publish your static files to GitHub Pages.


You can now find your GitHub Action Workflow and the workflow runs on this page. Click on your first run which was automatically created when you committed the workflow, and watch it publish your project to the 'gh-pages' branch:


After a few seconds to a minute, the GitHub Pages site should be available at '[YOUR_USERNAME].github.io/[YOUR_REPOSITORY_NAME]'.But you'll notice that your blazor application isn't working as expected. You'll be greeted with this:


which will build the website and make it available at :1313.In this mode Hugo will automatically re-generate your site whenever you change yoursources, which comes in handy while developing your contents.Initial state of the website before any modifications.


Due to extensive inline documentation, all files are more or less self-explaining. The content/subfolder contains all user-editable source files from which the website is built. For the initialsetup, disable all sections on the main homepage for which you do not have created your own contentyet by either deleting them from content/home or by moving them to a different folder.


In this tutorial, we will use academic-pages-demo as the host repository name, since my canonicalrepository name sloede.github.com is obviously already taken. Go to GitHub and create a newrepository, in my caseacademic-pages-demo.As per thedocumentation,your host repository needs to be public unless you are on a GitHub Pro account. This time, alsotick the box to initialize the repository with a README for testing purposes. On your newly createdhost repository site, go to Settings, scroll down to the GitHub Pages section and select masterbranch as your website source. Please note that in my case the URL differs from what you will seesince I have already set up acustom domain for my GitHub Pages.GitHub Pages settings to select which branch to serve as a website.


The corresponding commit to theacademic-kickstart-demorepository can be foundhere.You can verify that the workflow succeeded by going to your source repositorywebsite on GitHub - next to the latest commit info should be a small greencheckmark:This workflow succeeded without errors.If you see a small brown circle instead of the checkmark, your action is stillrunning. If the workflow indicator is a red cross, however, it means thatsomething went wrong.


The GitHub Actions used in these instructions pull source content from the main branch and then commit the generated content to the gh-pages branch. This applies regardless of what type of GitHub Pages you are using. This is a clean setup as your Hugo files are stored in one branch and your generated files are published into a separate branch.


By default, the GitHub action pushes the generated content to the gh-pages branch. This means GitHub has to serve your gh-pages branch as a GitHub Pages branch. You can change this setting by going to Settings > GitHub Pages, and change the source branch to gh-pages.


With github-pages, a website and its content can be easily hosted and managed through a regular github repository - just like the one you are looking at right now. Together with jekyll, a generator for static websites that uses markdown, content management becomes incredibly simple. Here is a short introduction to get a website up and running in a few minutes.


The first property we need to add at the top level homepage second we will define this as a string and the value will be " username is your GitHub username, and repo-name is the name of the GitHub repository you created it will look like this :


this command will create a branch named gh-pages this branch host your app, and homepage property you created in package.json file hold your link for a live preview, or you can open the branch setting scroll down to GitHub Pages section you will find this:


and now i keep getting this:Cloning into 'node_modules/gh-pages/.cache/git@github.com!Yuribenjamin!my-app.git'...git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.


and I still got this... Cloning into 'node_modules/gh-pages/.cache/git@github.com!Yuribenjamin!my-app.git'...git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.


"Cloning into 'node_modules/gh-pages/.cache/git@github.com!idongessien!idngessnio.git'...Warning: Permanently added the RSA host key for IP address '140.82.114.4' to the list of known hosts.git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.


I read that the gh-pages is supposed to create a new branch but that is not happening. I'm going to try to delete the repo and start from scratch. After I make a new repo, should I still be running the following setup commands?git initgit add README.mdgit commit -m "first commit"git remote add origin git@github.com:LKian/ToDoList.gitgit push -u origin master


Very nice post Ibrahim. Really helped me.I was able to deploy my page to gh pages. The only thing is that my background image is not loading.I have the image in my src folder. While running the app on my local server, The site was displaying my image perfectly. While i deploy on gh pages, image disappears.I have tried adding the image using jsx, but to no avail. Previously i imported the image to my scss. Thought that was the problem.Can someone tell me what's going on?app is deployed here- jaykeeshow.github.io/simple-app/


Hey thanks for your comment, handling route in react can easly done by using react router package, not by default way as i saw in your app, also read about Single Page App, and declaritive programming github.com/ReactTraining/react-routerHappy Hacking! 2ff7e9595c


 
 
 

Recent Posts

See All

Comments


© 2023 by EPS Marketing. Proudly created with Wix.com

bottom of page