我使用 pelican 作为静态站点生成器来构建静态站点。我想将它托管在 GitLab Pages 上,并通过 GitLab 与 Makefile 的持续集成让网站生成。
该站点通过其 CI/CD 管道在本地以及 GitLab 上成功构建。构建代码通过上传工件并且作业成功。内容文件在public
文件夹中构建和生成。
不知何故,在构建通过并public
根据需要将工件上传到文件夹中之后,预计静态站点将托管在 GitLab 页面的用户页面上,例如username.gitlab.io/projectname
.
尽管建议的等待时间是 15 分钟到半小时,但即使在 15 多个小时之后,这也不起作用。
还尝试了在自定义子域上托管。子域已验证,但未生成站点。
作为参考,下面提到了正在使用的最少代码。
.gitlab-ci.yml
# default to using the latest Python docker image for builds
image: python:3.7.0
# our build job installs the Python requirements and Pelican
# plugins, then runs ``make publish`` to generate the output
build:
stage: deploy
script:
- apt-get update -qq && apt-get install -y -qq python python-pip
- python -v
- pip install -r requirements.txt
- git clone --recursive https://github.com/getpelican/pelican-plugins ../plugins
- pelican -s publishconf.py
- make publish
# specify the artifacts to save
artifacts:
paths:
- public/
only:
- master
发布配置文件
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os
AUTHOR = 'Tanya Jain'
SITENAME = 'Tanya Jain'
SITEURL = '/public'
DESCRIPTION = ''
THEME = 'themes/stellarAdventurerTheme'
PATH = 'content'
OUTPUT_PATH = 'public'
鹈鹕配置文件
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os
AUTHOR = 'Tanya Jain'
SITENAME = 'Tanya Jain'
SITEURL = '/public'
DESCRIPTION = ''
THEME = 'themes/stellarAdventurerTheme'
PATH = 'content'
OUTPUT_PATH = 'public'
生成文件
PY?=python3
PELICAN?=pelican
PELICANOPTS=
BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/public
CONFFILE=$(BASEDIR)/pelicanconf.py
PUBLISHCONF=$(BASEDIR)/publishconf.py
FTP_HOST=localhost
FTP_USER=anonymous
FTP_TARGET_DIR=/
SSH_HOST=localhost
SSH_PORT=22
SSH_USER=root
SSH_TARGET_DIR=/var/www
请帮助您了解如何在 GitLab Pages 上生成网站!
更新1:
尝试了这些也不起作用的更改。然而,我相信这些更改将在 pelican 设置中进行,而不是在 GitLab 的 YAML 中进行。
鹈鹕配置文件
SITEURL = ''
发布配置文件
SITEURL = 'http://subdomain.example.com'