我使用 pelican 作为静态站点生成器来构建静态站点。我想将它托管在 GitLab 页面上,并让该站点通过 GitLab 与 Makefile 的持续集成生成。
该站点通过其 CI/CD 管道在本地和 GitLab 上成功构建。构建代码通过上传工件并且作业成功。内容文件在public
文件夹中构建和生成。
不知何故,在构建被传递并public
根据需要将工件上传到文件夹中后,预计静态站点将托管在 GitLab 页面的用户页面上,例如username.gitlab.io/projectname
.
尽管推荐的等待时间是 15 分钟到半小时,但即使在 15 多个小时之后这也不起作用。
还尝试了在自定义子域上托管。子域已验证,但未生成站点。
作为参考,下面提到了使用中的最少代码。
# 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 页面上生成站点!
尝试了这些更改也不起作用。然而,我相信这些更改将在 pelican 设置中进行,而不是在 GitLab 的 YAML 中进行。
SITEURL = ''
SITEURL = 'http://subdomain.example.com'
非常感谢您的帮助!我已经解决了这个问题。错误是由于build
在 .gitlab-ci.yml 中提到了 job并且还缺少 job pages
。使用pages
作为作业是GitLab页的必要性进行部署,可以在提及的参考文献进一步阅读。因此,正确的脚本应该是:
image: python:3.7.0
pages:
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
artifacts:
paths:
- public/
only:
- master
参考:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句