5.1 KiB
last_updated | author | author_gitlab | level | article_type | date |
---|---|---|---|---|---|
2018-02-16 | Marcia Ramos | marcia | beginner | user guide | 2017-02-22 |
Static sites and GitLab Pages domains
This document is the beginning of a comprehensive guide, made for those who want to publish a website with GitLab Pages but aren't familiar with the entire process involved.
This first document of this series will present you to the concepts of static sites, and go over how the default Pages domains work.
The second document covers how to get started with GitLab Pages: deploy a website from a forked project or create a new one from scratch.
The third document will show you how to set up a custom domain or subdomain to your site already deployed.
The fourth document will show you how to create and tweak GitLab CI for GitLab Pages.
To enable GitLab Pages for GitLab CE (Community Edition) and GitLab EE (Enterprise Edition), please read the admin documentation, and/or watch this video tutorial.
Note: For this guide, we assume you already have GitLab Pages server up and running for your GitLab instance.
What you need to know before getting started
Before we begin, let's understand a few concepts first.
Static sites
GitLab Pages only supports static websites, meaning, your output files must be HTML, CSS, and JavaScript only.
To create your static site, you can either hardcode in HTML, CSS, and JS, or use a Static Site Generator (SSG) to simplify your code and build the static site for you, which is highly recommendable and much faster than hardcoding.
Further reading
- Read through this technical overview on Static versus Dynamic Websites
- Understand how modern Static Site Generators work and what you can add to your static site
- You can use any SSG with GitLab Pages
- Fork an example project to build your website based upon
GitLab Pages domain
If you set up a GitLab Pages project on GitLab.com,
it will automatically be accessible under a
subdomain of namespace.gitlab.io
.
The namespace
is defined by your username on GitLab.com,
or the group name you created this project under.
Note: If you use your own GitLab instance to deploy your site with GitLab Pages, check with your sysadmin what's your Pages wildcard domain. This guide is valid for any GitLab instance, you just need to replace Pages wildcard domain on GitLab.com (
*.gitlab.io
) with your own.
Learn more about namespaces.
Practical examples
Project Websites
- You created a project called
blog
under your usernamejohn
, therefore your project URL ishttps://gitlab.com/john/blog/
. Once you enable GitLab Pages for this project, and build your site, it will be available underhttps://john.gitlab.io/blog/
. - You created a group for all your websites called
websites
, and a project within this group is calledblog
. Your project URL ishttps://gitlab.com/websites/blog/
. Once you enable GitLab Pages for this project, the site will live underhttps://websites.gitlab.io/blog/
. - You created a group for your engineering department called
engineering
, a subgroup for all your documentation websites calleddocs
, and a project within this subgroup is calledworkflows
. Your project URL ishttps://gitlab.com/engineering/docs/workflows/
. Once you enable GitLab Pages for this project, the site will live underhttps://engineering.gitlab.io/docs/workflows
.
User and Group Websites
- Under your username,
john
, you created a project calledjohn.gitlab.io
. Your project URL will behttps://gitlab.com/john/john.gitlab.io
. Once you enable GitLab Pages for your project, your website will be published underhttps://john.gitlab.io
. - Under your group
websites
, you created a project calledwebsites.gitlab.io
. your project's URL will behttps://gitlab.com/websites/websites.gitlab.io
. Once you enable GitLab Pages for your project, your website will be published underhttps://websites.gitlab.io
.
Support for subgroup project's websites was introduced in GitLab 11.8.
General example:
- On GitLab.com, a project site will always be available under
https://namespace.gitlab.io/project-name
- On GitLab.com, a user or group website will be available under
https://namespace.gitlab.io/
- On your GitLab instance, replace
gitlab.io
above with your Pages server domain. Ask your sysadmin for this information.
Read on about Projects for GitLab Pages and URL structure.