User Tools

Site Tools


Sidebar

Navigation

public:help:gitlab_pages

Hosting a static web page on GitLab

Page Disambiguation

GitLab offers a way to create and host web pages called GitLab Pages. The following article describes how to create a GitLab Pages project.
After creating, you can access your website via https://<user>.pages.enterpriselab.ch/<project>/. Your link looks something like this: https://iauser.pages.enterpriselab.ch/myproject
The official documentation can be found here: https://docs.gitlab.com/ee/user/project/pages/

It is assumed that the reader has an active Enterprise Lab account and is somewhat familiar with GitLab and Bash.

:NOTE: Server-side languages like PHP or nodeJS will not work with GitLab Pages.

New Project or Migration from user.enterpriselab.ch

This is the way to go when you are starting from scratch or if you already have a web page running under user.enterpriselab.ch and would like to migrate.

The easiest way is to create a new project under New project.
Then click on the Create from template tab and select Pages/Plain HTML. button
Finally, click on Use template and give the project a name.
More information about each template can be found with the button Preview.

If you're migrating from user.enterpriselab.ch, simply remove the contents of the public directory and replace them with the files from your public_html directory.
An elegant way to do this would be the following:

  • connect to an Enterprise Lab ressource like testbed05.el.eee.intern over ssh.
  • clone your new GitLab Pages project
    git clone https://gitlab.enterpriselab.ch/username/your-project.git
  • remove the default content.
    rm ~/your-project/public/*
  • copy your existing web page from public_html to the now empty public folder.
    cp ~/public_html/* ~/your-project/public/
  • commit your changes.
    cd ~/your-project
    git commit -a -m "migrated contents from user.enterpriselab.ch"
  • push your changes to GitLab.
    git push

Lastly, to make your website available after setting it up, you need to run the GitLab CI/CD pipeline. Subsequent changes to the repo (commits) will trigger the pipeline automatically by default. This means that changes will be deployed immediatly after they are made.

Existing project

If you already have an existing GitLab project and want to start using Pages with it, follow these instructions.
:NOTE: Should your project already contain a .gitlab-ci.yml it is necessary to merge the two. Read up on the documentation if you are unsure of how to do this.

1. Add the file .gitlab-ci.yml in the project root directory. This yml content comes from pages/Plain HTML project.
More about .gitlab-ci.yml can be found here: https://docs.gitlab.com/ee/ci/yaml/

image: alpine:latest
pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
  artifacts:
    paths:
    - public/
  only:
  - master

2. Add your index.html file in the subdirectory public.
For an example html file see below.

<html>
<head>
<title>Testpage</title>
</head>
<body>
<h1>Testpage</h1>
<p>Hello World!</p>
</body
</html>

Lastly, to make your website available after setting it up, you need to run the GitLab CI/CD pipeline. Subsequent changes to the repo (commits) will trigger the pipeline automatically by default. This means that changes will be deployed immediatly after they are made.

public/help/gitlab_pages.txt · Last modified: 2019-11-04T16:50+0100 by cvu