Skip to content
README.md 2.56 KiB
Newer Older
Markus Mößler's avatar
Markus Mößler committed
# example-pages

Markus Mößler's avatar
Markus Mößler committed
## Introduction

This is simple example to serve plain static files using gitlab pages.

Markus Mößler's avatar
Markus Mößler committed
Further information for generate pages can be found:

* [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/)
* [GitLab Pages access control](https://docs.gitlab.com/ee/user/project/pages/pages_access_control.html)
Markus Mößler's avatar
Markus Mößler committed

<!-- 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.