Git GitLab Pages
Host Your Page on GitLab Cloud
With GitLab Cloud, GitLab allows you to host a webpage from your repository. Let's try to use GitLab Cloud to host our repository.
Create a New Repository
Start by signing in to GitLab. GitLab Cloud needs a special name and setup to work, so we start by creating a new blank repository.
This repository needs a special name to function as a GitHub page. It needs to be your GitLab username/workspace ID
, followed by .gitlab.io
:
Push Local Repository to GitLab Cloud
We add this new repository as a remote for our local repository, we are calling it gl-pages
(for GitLab Pages).
Copy the URL
from here:
And add it as a new remote
:
Example
git remote add gl-pages https://gitlab.com/w3schools-test/w3schools-test.gitlab.io.git
Make sure you are on the master
branch
, then push the master
branch
to the new remote
:
Example
git push gl-pages master
Enumerating objects: 38, done.
Counting objects: 100% (38/38), done.
Delta compression using up to 16 threads
Compressing objects: 100% (38/38), done.
Writing objects: 100% (38/38), 94.66 KiB | 15.78 MiB/s, done.
Total 38 (delta 21), reused 0 (delta 0), pack-reused 0
To https://gitlab.com/w3schools-test/w3schools-test.gitlab.io.git
* [new branch] master -> master
Note: If this is the first time you are connecting to GitLab, you will get some kind of notification to authenticate this connection.
GitLab Site Configuration
GitLab has a lot of different configurations for sites available. But for this we need the configuration for a simple HTML site. Go to GitLab, confirm the files have been uploaded, and click "+" - "New file":
Select .gitlab-ci.yml
template, with HTML
:
Commmit with a message:
It takes a few minutes to set up. But after a little while you can use the repository name as an URL in your broweser to view the result!