GitLab Hosting

How to host a website on GitLab

Note if you have any dyanmic pages (eg. are using php) then you will need to use an alternative for hosting.

Information on GitLab pages may be found here.

One good thing about hosting on GitLab is thanks to using a .gitlab-ci.yaml file you do not need to have both a master and a stage branch. Hence when you use Nift to push changes remotely to your repository you do not need to, when needed, enter your password twice.

Importing/Forking an existing website repository

By far the easiest way to host a website on GitLab is to import or fork an existing site repository from GitLab or any other code sharing platform. See here for a variety of templates you can use to make websites.


On GitLab with url:
https://username.gitlab.io

  1. If you do not already have a GitLab account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here;
    Note: If you are new to Git and GitLab, do not confuse yourself about authenticating with GitLab from Git. You can follow the rest of these steps and educate yourself later.
  3. Create a new repository called username.gitlab.io, where username is your GitLab username;
  4. Open a terminal window and change to the directory you would like to store your repository in locally;
  5. Clone a local copy of your new repository by entering:
    git clone https://gitlab.com/username/username.gitlab.io.git
    
    where username is your GitLab username;
  6. Change into the repository directory by entering cd username.gitlab.io;
  7. Copy your site files (eg. content and template files, .gitlab-ci.yml and site directory) into the repository directory;
  8. Make sure a copy of this .gitlab-ci.yml file is in the repository directory;
  9. Enter the following into your terminal window:
    git status
    git add .
    git commit -m "added site files"
    git push origin master
    

  10. Your site, with url:
    https://username.gitlab.io
    
    should now be hosted and accessible from the internet.

To update your site, just repeat the steps following (and including) copying the site files into the repository directory.

On GitLab with url:
https://username.gitlab.io/site-name

  1. If you do not already have a GitLab account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here;
    Note: If you are new to Git and GitLab, do not confuse yourself about authenticating with GitLab from Git. You can follow the rest of these steps and educate yourself later.
  3. Create a new repository called site-name, you may choose any name you like;
  4. Open a terminal window and change to the directory you would like to store your repository in locally;
  5. Clone a local copy of your new repository by entering:
    git clone https://gitlab.com/<i>username</i>/<i>site-name</i>.git
    
    where username is your GitLab username;
  6. Change into the repository directory by entering cd site-name;
  7. Copy your site files (eg. content and template files, .gitlab-ci.yml and site directory) into the repository directory;
  8. Make sure a copy of this .gitlab-ci.yml file is in the repository directory;
  9. Enter the following into your terminal window:
    git status
    git add .
    git commit -m "added site files"
    git push origin master
    

  10. Your site, with url:
    https://username.gitlab.io/site-name
    
    should now be hosted and accessible from the internet.

To update your site, just repeat the steps following (and including) copying the site files into the repository directory.