Simiki

Deploy

Deployment is related to the content of content directory.

Below list some common deployment mode/method, which support basic command tool, or based on fabfile

Self-Managed Server

Use rsync or scp command, transfer the content of output directory to the root path of your server, configured with Web Server(Such as Nginx, Apache, etc.)

If use Fabric, you need to add deploy settings in _config.yml:

deploy:
  - type: rsync
    user: <login username>
    host: <remote host ip or domain>
    dir: <path to store files/dirs under output>

This will transfer the sub-file/sub-directory under output to the remote server, with configured directory path, base on Rsync with SSH.

If you don't want to enter password every time, you can configure SSH Private/Public Key

Run deploy command:

$ fab deploy

FTP Server

Use sftp or ftp command, upload the content of output directory to the root path of your server, configured from the background of server service provider.

If use Fabric, you need to add deploy settings in _config.yml:

deploy:
  - type: ftp
    host: <remote host ip or domain>
    port: <remote host port, default is 21>
    user: <login username>
    password: <login password>
    dir: <path to store files/dirs under output>

This will upload the sub-file/sub-directory under output to the remote server, with configured directory path, base on FTP.

About password field:

NOTE: If configured password, DO NOT to put this config file to public server, such as Github public repository!

Advice: Configure password with empty value, this will let you enter password every time:

deploy:
  - type: ftp
    host: 1.1.1.1
    user: bob
    password:         # Leave this value be empty
    dir: /

Run deploy command:

$ fab deploy

Github Pages

Github Pages helps you build your own site, without to buy VPS/Virtual Host.

If use Fabric, you need to add deploy settings in _config.yml:

deploy:
  - type: git
    remote: <remote repo name, default is 'origin'>
    branch: <branch, default is 'gh-pages'>

This will push the sub-file/sub-directory under output to the remote repository, with configured branch, based on Git.

NOTE:

Run deploy command:

$ fab deploy

For Github Pages, with default settings, ghp-import actually executes ghp-import -p -m "Update output documentation" -r origin -b gh-pages output. ghp-import is a open-source tool, it can commit the changes of specific directory (e.g. output directory) to gh-pages branch and push to Github. ghp-import will traverse all the files under specific directory, and use the backend command git fast-import, add or modify the file to git repository one by one.

(The End ...)


Note: Below procedures are another way to deploy for Github Pages, not the same as above way using ghp-import, and this need to manually configure, very complicated. At present, this method is deprecated, and is no longer maintained.

More details are give in Github Pages Documentation

User Pages

Create User Pages.

  1. Create a repository named <username>.github.io. <username> is your Github's username.

  2. Into your local site, setup a master branch in output directory:

    cd output
    git init
    git add .
    git commit -m 'your comment'
    # These steps will be shown when you create a repo in Github:
    git remote add origin https://github.com/<username>/<username>.github.io.git
    git push -u origin master
    
  3. Back to the parent directory, and create a .gitignore file:

    cd ../
    echo -e '*.pyc\noutput' > .gitignore
    
  4. Setup a source branch:

    git init
    git checkout -b source
    git add .
    git commit -m 'your comment'
    # These steps will be shown when you create a repo in Github:
    git remote add origin https://github.com/<username>/<username>.github.io.git
    git push -u origin source
    

Wait for a while and visit http://<username>.github.io/.

The way to bind domain on User Pages can refer to the Project Pages.

Project Pages

Project Pages have two types:

With Custom Domain

  1. Create a repository with any name <projectname>.

  2. Into your local site, setup a gh-pages branch in output directory:

    cd output
    git init
    git checkout -b gh-pages
    git add .
    git commit -m 'your comment'
    # These steps will be shown when you create a repo in Github:
    git remote add origin git@github.com:<username>/<projectname>.git
    git push -u origin gh-pages
    
  3. Back to the parent directory, and create a .gitignore file:

    cd ../
    echo -e '*.pyc\noutput' > .gitignore
    
  4. Setup a master branch:

    git init
    
    # Write your domain to file named CNAME, locate under root of site
    echo "<yourdomain.com>" > CNAME
    
    git add .
    git commit -m 'your comment'
    # These steps will be shown when you create a repo in Github:
    git remote add origin git@github.com:<username>/<projectname>.git
    git push -u origin master
    

Wait for a while and visit http://<yourdomain.com>

Note:

More Reference:

An example:

Without Custom Domain

The project pages url is http://<username>.github.io/<projectname>, so you should set root to your projectname in _config.yml:

root: /<projectname>

The others are the same as Project Pages with Custom Doamin above.

An example: