Newer
Older
## Introduction
This is simple example to serve plain static files using gitlab pages.
Further information for generate pages can be found here: [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/)
The access controll via OAuth is not configured yet. However the gitlab page of private repositories looks like
* Public: [https://mmoessler.aidaho-pages.uni-hohenheim.de/example-pages/](https://mmoessler.aidaho-pages.uni-hohenheim.de/example-pages/)
* Private: [https://example-private-pages-c883cb.aidaho-pages.uni-hohenheim.de/](https://example-private-pages-c883cb.aidaho-pages.uni-hohenheim.de/)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!-- Follow these steps to create a GitLab Pages site hosted under a custom external URL like `https://mmoessler.aidaho-pages.uni-hohenheim.de/example-pages/`. -->
---
## Step 1: Set Up a GitLab Project
1. **Log in to GitLab**: Go to your GitLab account.
2. **Create a New Project**:
- Click the **New Project** button.
- Choose between creating a blank project, importing an existing one, or using a template.
- Give the project a name, e.g., `my-pages-site`.
- Ensure the project is **Public** if you want the GitLab Pages site to be accessible to everyone.
---
## Step 2: Add a Configuration File
1. **Clone the Repository**:
- Use the GitLab web interface to copy the repository URL.
- Clone it to your local machine:
```bash
git clone <repository-url>
```
2. **Add a GitLab Pages Configuration**:
- Add a `.gitlab-ci.yml` file to the root of your repository with the following content:
```yaml
pages:
stage: deploy
script:
- mkdir .public
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
only:
- main
```
- This script assumes your site's static files are in the root directory. Adjust as needed for your project.
---
## Step 3: Push Your Code
1. **Add Your Static Files**:
- Place your website's HTML, CSS, and JavaScript files in the project directory.
2. **Commit and Push**:
- Commit your changes:
```bash
git add .
git commit -m "Initial commit for GitLab Pages"
git push origin main
```
---
## Step 4: Configure GitLab Pages
1. **Enable Pages in Your Project Settings**:
- Go to your project in GitLab.
- Navigate to **Settings > Pages**.
- Verify that your Pages are enabled and note the URL provided by GitLab for your site (e.g., `[https://<username>.gitlab.io/<project-name>](https://mmoessler.aidaho-pages.uni-hohenheim.de/example-pages/)`).
---
## Step 5: Test Your Site
1. **Access Your Site**:
- Open your browser and visit `https://aidaho-pages.uni-hohenheim.de`.
- Ensure everything loads correctly.
---
You now have a GitLab Pages site hosted at your custom domain! If you encounter any issues during the setup, revisit the steps or seek assistance.