PageSourceSearch

http://segfaulted.com/pelican-on-gitlab-pages.html

html segfaulted.com collected 2026-10-07 19:37:28 UTC 13,614 bytes, 231 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en">
3<head>
4        <meta charset="utf-8" />
5        <title>Pelican on GitLab Pages</title>
6        <link rel="stylesheet" href="http://segfaulted.com/theme/css/main.css" />
7        <link href="http://segfaulted.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Segfaulted's Blog Atom Feed" />
8
9        <!--[if IE]>
10            
10<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
10
11        <![endif]-->
12</head>
13
14<body id="index" class="home">
15        <header id="banner" class="body">
16                <h1><a href="http://segfaulted.com/">Segfaulted's Blog </a></h1>
17                <nav><ul>
18                    <li class="active"><a href="http://segfaulted.com/category/web.html">Web</a></li>
19                </ul>
20                </nav>
21        </header><!-- /#banner -->
22<section id="content" class="body">
23  <article>
24    <header>
25      <h1 class="entry-title">
26        <a href="http://segfaulted.com/pelican-on-gitlab-pages.html" rel="bookmark"
27           title="Permalink to Pelican on GitLab Pages">Pelican on GitLab Pages</a></h1>
28    </header>
29
30    <div class="entry-content">
31<footer class="post-info">
32        <span>Thu 25 May 2017</span>
33<span>| tags: <a href="http://segfaulted.com/tag/pelican.html">Pelican</a><a href="http://segfaulted.com/tag/gitlab.html">GitLab</a></span>
34</footer><!-- /.post-info -->      <p>This guide assumes you know how to install software on the computer operating
35system you are using and you are familiar with the basics of using GitLab.</p>
36<div class="section" id="getting-started">
37<h2>Getting Started</h2>
38<div class="section" id="required-software">
39<h3>Required Software</h3>
40<ul class="simple">
41<li>Git - <a class="reference external" href="http://git-scm.com">Git</a> or any other Git client.</li>
42<li>Python 2.7 or 3.3+ - <a class="reference external" href="http://www.python.org">Python.org</a></li>
43<li>virtualenv - install covered below</li>
44</ul>
45</div>
46<div class="section" id="project-setup">
47<h3>Project Setup</h3>
48<p>Create a repository on GitLab for your new website. It can be public or private,
49your website will be viewable publicly either way. There are a couple options when
50creating your site on GitLab. If you create your repository under
51&lt;username&gt;/&lt;username&gt;.gitlab.io, your website will be available at
52<a class="reference external" href="http:/">http:/</a>/&lt;username&gt;.gitlab.io. This also works for groups, just replace &lt;username&gt;
53with your groups name. If you create your repository at
54&lt;username&gt;/&lt;projectname&gt; your website will be available at
55<a class="reference external" href="http:/">http:/</a>/&lt;username&gt;.gitlab.io/&lt;projectname&gt;. Again, this always works with groups,
56just replace &lt;username&gt; with the name of your group.</p>
57<p>Now clone the repository you just created.</p>
58<div class="highlight"><pre><span></span>$ git clone [email protected]:&lt;username&gt;/&lt;reponame&gt;.git reponame
59$ <span class="nb">cd</span> reponame
60</pre></div>
61<p>Replace &lt;username&gt; and &lt;reponame&gt; with your username or group name and the name
62of the repository you created earlier.</p>
63<p>If you are using a GUI Git client you need to open a terminal/console window and
64navigate to the folder you cloned the repository to.</p>
65</div>
66</div>
67<div class="section" id="pelican">
68<h2>Pelican</h2>
69<p>After you have your repository created and the required software installed its time to install Pelican.</p>
70<div class="section" id="install-virtualenv">
71<h3>Install virtualenv</h3>
72<div class="section" id="linux-and-os-x">
73<h4>Linux and OS X</h4>
74<div class="highlight"><pre><span></span>$ sudo pip install virtualenv
75</pre></div>
76<p>Restart your terminal</p>
77<div class="highlight"><pre><span></span>$ virtualenv &lt;path&gt;
78</pre></div>
79<p>Where &lt;path&gt; is the directory you want to save the virtualenv files. Usually something like /home/&lt;username&gt;/virtualenvs/pelican on Linux
80or /Users/&lt;UserName&gt;/virtualenvs/pelican on OS X.</p>
81<p>Whenever you need work in the virtualenv:</p>
82<div class="highlight"><pre><span></span>$ <span class="nb">source</span> &lt;path&gt;/bin/activate
83</pre></div>
84</div>
85<div class="section" id="windows">
86<h4>Windows</h4>
87<div class="highlight"><pre><span></span>c<span class="p">:</span><span class="nl">\</span><span class="c1">&gt;pip install virtualenv</span>
88c<span class="p">:</span><span class="nl">\</span><span class="c1">&gt;virtualenv &lt;path&gt;</span>
89</pre></div>
90<p>Where &lt;path&gt; is the directory you want to save the virtual env files. Usually something like c:Users&lt;Username&gt;virtualenvspelican</p>
91<p>Whenever you need to work in the virtualenv:</p>
92<div class="highlight"><pre><span></span>c<span class="p">:</span><span class="nl">\</span><span class="c1">&gt; &lt;path&gt;\Scripts\activate</span>
93</pre></div>
94</div>
95</div>
96<div class="section" id="install-pelican">
97<h3>Install Pelican</h3>
98<p>Make sure your virtualenv is activated and install pelican.</p>
99<div class="highlight"><pre><span></span>$ pip install pelican markdown
100</pre></div>
101</div>
102<div class="section" id="generate-the-base-site">
103<h3>Generate the Base Site</h3>
104<p>With your virtualenv still active.</p>
105<div class="highlight"><pre><span></span>$ mkdir blogname
106$ <span class="nb">cd</span> blogname
107$ pelican-quickstart
108Welcome to pelican-quickstart v3.7.1.
109This script will <span class="nb">help</span> you create a new Pelican-based website.
110Please answer the following questions so this script can generate the files
111needed by Pelican.
112
113&gt; Where <span class="k">do</span> you want to create your new web site? <span class="o">[</span>.<span class="o">]</span> &lt;enter&gt;
114&gt; What will be the title of this web site? My Blog &lt;enter&gt;
115&gt; Who will be the author of this web site? My Name &lt;enter&gt;
116&gt; What will be the default language of this web site? <span class="o">[</span>en<span class="o">]</span> &lt;enter&gt;
117&gt; Do you want to specify a URL prefix? e.g., http://example.com   <span class="o">(</span>Y/n<span class="o">)</span> n &lt;enter&gt;
118&gt; Do you want to <span class="nb">enable</span> article pagination? <span class="o">(</span>Y/n<span class="o">)</span> &lt;enter&gt;
119&gt; How many articles per page <span class="k">do</span> you want? <span class="o">[</span><span class="m">10</span><span class="o">]</span> &lt;enter&gt;
120&gt; What is your <span class="nb">time</span> zone? <span class="o">[</span>Europe/Paris<span class="o">]</span> America/Chicago &lt;enter&gt;
121&gt; Do you want to generate a Fabfile/Makefile to automate generation and publishing? <span class="o">(</span>Y/n<span class="o">)</span> &lt;enter&gt;
122&gt; Do you want an auto-reload <span class="p">&amp;</span> simpleHTTP script to assist with theme and site development? <span class="o">(</span>Y/n<span class="o">)</span> &lt;enter&gt;
123&gt; Do you want to upload your website using FTP? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
124&gt; Do you want to upload your website using SSH? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
125&gt; Do you want to upload your website using Dropbox? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
126&gt; Do you want to upload your website using S3? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
127&gt; Do you want to upload your website using Rackspace Cloud Files? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
128&gt; Do you want to upload your website using GitHub Pages? <span class="o">(</span>y/N<span class="o">)</span> &lt;enter&gt;
129Done. Your new project is available at /home/&lt;username&gt;/blogname
130</pre></div>
131<p>For most the most part you can leave all the defaults to the yes and now questions. Make sure to fill in the title of the website,
132author of the website and time zone.</p>
133</div>
134<div class="section" id="setup-for-gitlab">
135<h3>Setup for GitLab</h3>
136<p>By default Pelican outputs the generated files to a folder named &quot;output&quot;, this
137won't work with GitLab. Open the file pelicanconf.py and add the following line.</p>
138<div class="highlight"><pre><span></span><span class="n">OUTPUT_PATH</span> <span class="o">=</span> <span class="s1">&#39;public&#39;</span>
139</pre></div>
140<p>You can also customize any other options you wish in this file.</p>
141<p>Navigate to your repository's Settings, and go to CI/CD Pipelines. Make sure
142&quot;Shared Runners&quot; is enabled.</p>
143<p>In order to tell GitLab we need Pelican installed to build out site, we need to
144add a requirements.txt file.</p>
145<div class="highlight"><pre><span></span>pelican
146markdown
147</pre></div>
148<p>Next we need to make the configuration file to actually build and deploy our site to
149GitLab. Create a new file named .gitlab-ci.yml and add the following lines to it.</p>
150<div class="highlight"><pre><span></span><span class="l l-Scalar l-Scalar-Plain">image</span><span class="p p-Indicator">:</span> <span class="l l-Scalar l-Scalar-Plain">python:3.6-alpine</span>
151
152<span class="l l-Scalar l-Scalar-Plain">pages</span><span class="p p-Indicator">:</span>
153  <span class="l l-Scalar l-Scalar-Plain">script</span><span class="p p-Indicator">:</span>
154  <span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">pip install -r requirements.txt</span>
155  <span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">pelican -s publishconf.py</span>
156  <span class="l l-Scalar l-Scalar-Plain">artifacts</span><span class="p p-Indicator">:</span>
157    <span class="l l-Scalar l-Scalar-Plain">paths</span><span class="p p-Indicator">:</span>
158    <span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">public/</span>
159</pre></div>
160<p>Since we don't have any content written yet, we need to add a .gitkeep file to
161out content folder. Because Git doesn't track empty directories we add a blank
162file to our content folder so that it exists when the build tool runs on GitLab's
163servers. On windows simply make a empty text file and rename it .gitkeep. On Linux
164or OS X you can do <code>touch content/.gitkeep</code>.</p>
165<p>Finally we are ready to test. We must stage the new/changed files, commit them
166to Git then push them to GitLab where the site is built and published.</p>
167<div class="highlight"><pre><span></span>$ git add .
168$ git commit -m <span class="s2">&quot;Inital Commit&quot;</span>
169$ git push origin master
170</pre></div>
171<p>Navigate to your project on GitLab and go to &quot;Pipelines&quot;. You should either see
172a task running or completed or possibly failed. If the task is still running just
173wait till it is complete. If the task fails you can click the &quot;Failed&quot; button and
174go to &quot;Failed Jobs&quot; and get a build log to help you figure out where it went wrong.</p>
175<p>Once the task as completed successfully you should be able to view your site at
176<a class="reference external" href="http:/">http:/</a>/&lt;username/groupname&gt;.gitlab.io or <a class="reference external" href="http:/">http:/</a>/&lt;username/groupname&gt;.gitlab.io/projectname.</p>
177</div>
178<div class="section" id="adding-new-editing-posts">
179<h3>Adding New/Editing Posts</h3>
180<p>To add or edit posts just repeat the final step.</p>
181<div class="highlight"><pre><span></span>$ git add .
182$ git commit -m <span class="s2">&quot;Some Descriptive Message&quot;</span>
183$ git push origin master
184</pre></div>
185<p>Thats it! I hope you found this guide useful.</p>
186</div>
187</div>
188
189    </div><!-- /.entry-content -->
190    <a class="muut" href="https://muut.com/i/segfaulteds-blog/comments" type="dynamic">segfaulteds-blog</a> 
190<script src="//cdn.muut.com/1/moot.min.js"></script>
190
191
192
193  </article>
194</section>
195        <section id="extras" class="body">
196                <div class="blogroll">
197                        <h2>blogroll</h2>
198                        <ul>
199                            <li><a href="http://getpelican.com/">Pelican</a></li>
200                            <li><a href="http://python.org/">Python.org</a></li>
201                            <li><a href="http://jinja.pocoo.org/">Jinja2</a></li>
202                            <li><a href="#">You can modify those links in your config file</a></li>
203                        </ul>
204                </div><!-- /.blogroll -->
205                <div class="social">
206                        <h2>social</h2>
207                        <ul>
208                            <li><a href="http://segfaulted.com/feeds/all.atom.xml" type="application/atom+xml" rel="alternate">atom feed</a></li>
209
210                            <li><a href="#">You can add links in your config file</a></li>
211                            <li><a href="#">Another social link</a></li>
212                        </ul>
213                </div><!-- /.social -->
214        </section><!-- /#extras -->
215
216        <footer id="contentinfo" class="body">
217                <p>Powered by <a href="http://getpelican.com/">Pelican</a>. Theme <a href="https://github.com/blueicefield/pelican-blueidea/">blueidea</a>, inspired by the default theme.</p>
218        </footer><!-- /#contentinfo -->
219
220    
220<script type="text/javascript">
221    var _gaq = _gaq || [];
222    _gaq.push(['_setAccount', 'UA-69213474-1']);
223    _gaq.push(['_trackPageview']);
224    (function() {
225        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
226        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
227        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
228    })();
229    </script>
229
230</body>
231</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.