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<username>/<username>.gitlab.io, your website will be available at 52<a class="reference external" href="http:/">http:/</a>/<username>.gitlab.io. This also works for groups, just replace <username> 53with your groups name. If you create your repository at 54<username>/<projectname> your website will be available at 55<a class="reference external" href="http:/">http:/</a>/<username>.gitlab.io/<projectname>. Again, this always works with groups, 56just replace <username> 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]:<username>/<reponame>.git reponame 59$ <span class="nb">cd</span> reponame 60</pre></div> 61<p>Replace <username> and <reponame> 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 <path> 78</pre></div> 79<p>Where <path> is the directory you want to save the virtualenv files. Usually something like /home/<username>/virtualenvs/pelican on Linux 80or /Users/<UserName>/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> <path>/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">>pip install virtualenv</span> 88c<span class="p">:</span><span class="nl">\</span><span class="c1">>virtualenv <path></span> 89</pre></div> 90<p>Where <path> is the directory you want to save the virtual env files. Usually something like c:Users<Username>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">> <path>\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> Where <span class="k">do</span> you want to create your new web site? <span class="o">[</span>.<span class="o">]</span> <enter> 114> What will be the title of this web site? My Blog <enter> 115> Who will be the author of this web site? My Name <enter> 116> What will be the default language of this web site? <span class="o">[</span>en<span class="o">]</span> <enter> 117> Do you want to specify a URL prefix? e.g., http://example.com <span class="o">(</span>Y/n<span class="o">)</span> n <enter> 118> Do you want to <span class="nb">enable</span> article pagination? <span class="o">(</span>Y/n<span class="o">)</span> <enter> 119> 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> <enter> 120> What is your <span class="nb">time</span> zone? <span class="o">[</span>Europe/Paris<span class="o">]</span> America/Chicago <enter> 121> Do you want to generate a Fabfile/Makefile to automate generation and publishing? <span class="o">(</span>Y/n<span class="o">)</span> <enter> 122> Do you want an auto-reload <span class="p">&</span> simpleHTTP script to assist with theme and site development? <span class="o">(</span>Y/n<span class="o">)</span> <enter> 123> Do you want to upload your website using FTP? <span class="o">(</span>y/N<span class="o">)</span> <enter> 124> Do you want to upload your website using SSH? <span class="o">(</span>y/N<span class="o">)</span> <enter> 125> Do you want to upload your website using Dropbox? <span class="o">(</span>y/N<span class="o">)</span> <enter> 126> Do you want to upload your website using S3? <span class="o">(</span>y/N<span class="o">)</span> <enter> 127> Do you want to upload your website using Rackspace Cloud Files? <span class="o">(</span>y/N<span class="o">)</span> <enter> 128> Do you want to upload your website using GitHub Pages? <span class="o">(</span>y/N<span class="o">)</span> <enter> 129Done. Your new project is available at /home/<username>/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 "output", 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">'public'</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"Shared Runners" 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">"Inital Commit"</span> 169$ git push origin master 170</pre></div> 171<p>Navigate to your project on GitLab and go to "Pipelines". 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 "Failed" button and 174go to "Failed Jobs" 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>/<username/groupname>.gitlab.io or <a class="reference external" href="http:/">http:/</a>/<username/groupname>.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">"Some Descriptive Message"</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.