🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# GitLab Pages domain names, URLs, and baseurls > 原文:[https://docs.gitlab.com/ee/user/project/pages/getting_started_part_one.html](https://docs.gitlab.com/ee/user/project/pages/getting_started_part_one.html) * [GitLab Pages default domain names](#gitlab-pages-default-domain-names) * [Project website examples](#project-website-examples) * [User and Group website examples](#user-and-group-website-examples) * [URLs and baseurls](#urls-and-baseurls) * [Custom domains](#custom-domains) # GitLab Pages domain names, URLs, and baseurls[](#gitlab-pages-domain-names-urls-and-baseurls "Permalink") 在本文档中,了解如何根据所需网站的 URL 为 GitLab Pages 命名项目. ## GitLab Pages default domain names[](#gitlab-pages-default-domain-names "Permalink") > **注意:**如果您使用自己的 GitLab 实例通过 GitLab Pages 部署站点,请与 sysadmin 一起检查什么是 Pages 通配符域. 本指南适用于任何 GitLab 实例,您只需要用自己的实例替换 GitLab.com( `*.gitlab.io` )上的 Pages 通配符域. 如果您在 GitLab 上设置了 GitLab Pages 项目,则可以在`namespace.example.io`的子域下自动访问它. [`namespace`](../../group/index.html#namespaces)由您在 GitLab.com 上的用户名或在其下创建此项目的组名定义. 对于 GitLab 自我管理的实例,将`example.io`替换为实例的 Pages 域. 对于 GitLab.com,页面域为`*.gitlab.io` . | GitLab 页面的类型 | The name of the project created in GitLab | 网址 | | --- | --- | --- | | 用户页面 | `username.example.io` | `http(s)://username.example.io` | | 组页面 | `groupname.example.io` | `http(s)://groupname.example.io` | | 用户拥有的项目页面 | `projectname` | `http(s)://username.example.io/projectname` | | 小组拥有的项目页面 | `projectname` | `http(s)://groupname.example.io/projectname` | | 子组拥有的项目页面 | `subgroup/projectname` | `http(s)://groupname.example.io/subgroup/projectname` | **警告:**关于在通用域名和 HTTPS 下提供的名称空间存在一些已知[限制](introduction.html#limitations) . 确保阅读该部分. 要清楚地了解 Pages 域,请阅读以下示例. ### Project website examples[](#project-website-examples "Permalink") * 您在用户名`john`下创建了一个名为`blog`的项目,因此您的项目 URL 为`https://gitlab.com/john/blog/` . 为该项目启用 GitLab Pages 并构建您的网站后,即可在`https://john.gitlab.io/blog/`下找到该网站. * 您为所有网站创建了一个组,称为`websites` ,该组中的一个项目称为`blog` . 您的项目 URL 为`https://gitlab.com/websites/blog/` . 为该项目启用 GitLab 页面后,该站点将位于`https://websites.gitlab.io/blog/`下. * 您为工程部门创建了一个名为`engineering`的组,为所有文档网站创建了一个名为`docs`的子组,该子组中的一个项目称为`workflows` . 您的项目网址为`https://gitlab.com/engineering/docs/workflows/` . 为该项目启用 GitLab 页面后,该站点将位于`https://engineering.gitlab.io/docs/workflows`下. ### User and Group website examples[](#user-and-group-website-examples "Permalink") * 在您的用户名`john` ,您创建了一个名为`john.gitlab.io`的项目. 您的项目 URL 将为`https://gitlab.com/john/john.gitlab.io` . 为项目启用 GitLab Pages 后,您的网站将发布在`https://john.gitlab.io`下. * 在小组`websites` ,您创建了一个名为`websites.gitlab.io`的项目. 您项目的 URL 将为`https://gitlab.com/websites/websites.gitlab.io` . 为项目启用 GitLab Pages 后,您的网站将发布在`https://websites.gitlab.io`下. **一般示例:** * 在 GitLab.com 上,项目站点将始终在`https://namespace.gitlab.io/project-name`下可用 * 在 GitLab.com 上,将在`https://namespace.gitlab.io/`下提供用户或组网站. * 在您的 GitLab 实例上,将上述`gitlab.io`替换为 Pages 服务器域. 向您的系统管理员询问此信息. ## URLs and baseurls[](#urls-and-baseurls "Permalink") 每个静态网站发生器(SSG)的默认配置期望找到您的网站下一个(子)域( `example.com` ),而不是在该领域(的子目录`example.com/subdir` ). 因此,每当发布项目网站( `namespace.gitlab.io/project-name` )时,都必须在 SSG 文档中查找此配置(基本 URL)并进行设置以反映此模式. 例如,对于 Jekyll 站点, `baseurl`是在 Jekyll 配置文件`_config.yml`定义的. 如果您的网站 URL 是`https://john.gitlab.io/blog/` ,则需要将此行添加到`_config.yml` : ``` baseurl: "/blog" ``` 相反,如果您在派生我们的[默认示例](https://gitlab.com/pages)之一后部署网站,则已经以这种方式配置了 baseurl,因为所有示例都包含项目网站. 如果您决定将自己的网站设为用户或网上论坛,则必须从项目中删除此配置. 对于我们刚刚提到的 Jekyll 示例,您必须将 Jekyll 的`_config.yml`更改为: ``` baseurl: "" ``` ## Custom domains[](#custom-domains "Permalink") GitLab 页面支持通过 HTTP 或 HTTPS 提供服务的自定义域和子域. 有关更多信息,请参见[GitLab Pages 自定义域和 SSL / TLS 证书](custom_domains_ssl_tls_certification/index.html) .