git - Set subdirectory as website root on Github Pages -


i'm using github pages host & serve static website.

the static website has typical directory structure app:

|_ source |_ build    |_index.html  .gitignore  config.rb  gemfile  ...  readme.md 

index.html underbuild/, want make default www path.

so when users hit username.github.io renders content within subdirectory , yet doesn't show "/build"/ on url, cause that's set root folder.

notes:

  • i don't have custom domain nor planning 1 purpose. can see, i'm trying leverage default url naming convention github provides.
  • not using jekyll nor automatic page generator function.

there detailed gist required steps.

the gist here:
https://gist.github.com/cobyism/4730490


from gist

deploying subfolder github pages

sometimes want have subdirectory on master branch root directory of repository’s gh-pages branch. useful things sites developed yeoman, or if have jekyll site contained in master branch alongside rest of code.

for sake of example, let’s pretend subfolder containing site named dist.

step 1

remove dist directory project’s .gitignore file (it’s ignored default yeoman).

step 2

make sure git knows subtree (the subfolder site).

git add dist && git commit -m "initial dist subtree commit" 

step 3

use subtree push send gh-pages branch on github.

git subtree push --prefix dist origin gh-pages 

boom. if folder isn’t called dist, you’ll need change in each of commands above.


if on regular basis, create script containing following somewhere in path:

#!/bin/sh if [ -z "$1" ]   echo "which folder want deploy github pages?"   exit 1 fi git subtree push --prefix $1 origin gh-pages 

which lets type commands like:

git gh-deploy path/to/your/site 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -