<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pelican on Such geek. Wow.</title><link>https://www.ericlight.com/tags/pelican.html</link><description>Recent content in Pelican on Such geek. Wow.</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 12 Jan 2018 00:00:00 +1300</lastBuildDate><atom:link href="https://www.ericlight.com/tags/pelican/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting rid of the &lt;url&gt;#&lt;slug&gt; format in Flex</title><link>https://www.ericlight.com/post/pelican-urls.html</link><pubDate>Fri, 12 Jan 2018 00:00:00 +1300</pubDate><guid>https://www.ericlight.com/post/pelican-urls.html</guid><description>&lt;p&gt;Back when I was getting this blog set up, I had a &lt;a class="link" href="https://www.ericlight.com/post/pelican-config.html" &gt;short whinge&lt;/a&gt; about the default way that the &lt;a class="link" href="https://github.com/alexandrevicenzi/Flex" target="_blank" rel="noopener"
 &gt;Flex theme&lt;/a&gt; created links to pages.&lt;/p&gt;
&lt;p&gt;Specficially, creating a link to &amp;ldquo;&lt;a class="link" href="https://www.ericlight.com/post/tuna-patties.html" &gt;Tuna Patties&lt;/a&gt;&amp;rdquo; (for example), Flex would append the link with an identical stub, such as &lt;a class="link" href="https://www.ericlight.com/tuna-patties.html#tuna-patties" target="_blank" rel="noopener"
 &gt;https://www.ericlight.com/tuna-patties.html#tuna-patties&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I thought this was silly, so I found a way to fix it, but never bothered submitting a Pull Request to Alexandre because I figured it was intentional.&lt;/p&gt;
&lt;p&gt;Well, it turns out I wasn&amp;rsquo;t the only one. The good &lt;a class="link" href="https://github.com/DmytroLitvinov" target="_blank" rel="noopener"
 &gt;Dmytro Litvinov&lt;/a&gt; thought the same, and he created a &lt;a class="link" href="https://github.com/alexandrevicenzi/Flex/pull/88" target="_blank" rel="noopener"
 &gt;Pull Request&lt;/a&gt; to fix it, almost a whole year ago!&lt;/p&gt;
&lt;p&gt;Now, you can avoid this behaviour by simply adding &lt;code&gt;DISABLE_URL_HASH = True&lt;/code&gt; to your &lt;code&gt;pelicanconf.py&lt;/code&gt;!&lt;/p&gt;</description></item><item><title>Tidying up Pelican's URLs with the Flex theme</title><link>https://www.ericlight.com/post/pelican-config.html</link><pubDate>Sun, 23 Oct 2016 00:00:00 +1300</pubDate><guid>https://www.ericlight.com/post/pelican-config.html</guid><description>&lt;p&gt;This is just a brain-dump of tweaks I&amp;rsquo;ve made to my Pelican environment to get tidy URLs. In summary: One theme tweak, one Nginx tweak.&lt;/p&gt;
&lt;h2 id="making-the-flex-theme-drop-the-ugly-urlslug-format"&gt;Making the Flex Theme drop the ugly url#slug format:
&lt;/h2&gt;&lt;p&gt;I&amp;rsquo;ve decided I&amp;rsquo;m going to roll with the &lt;a class="link" href="https://github.com/alexandrevicenzi/Flex" target="_blank" rel="noopener"
 &gt;Flex&lt;/a&gt; theme for a while. I like it, but it had this habit of putting anchors and slugs into my article URLs.&lt;/p&gt;
&lt;p&gt;For example, my first page is known to Pelican as &amp;ldquo;welcome-to-the-internet&amp;rdquo;. However, links to the page were automatically created as &amp;ldquo;welcome-to-the-internet#welcome-to-the-internet&amp;rdquo;. It seems redundant. Also, it says the same thing twice. It repeats itself.&lt;/p&gt;
&lt;p&gt;I discovered the issue in the Flex theme. It&amp;rsquo;s under /templates/index.html, circa lines 7 and 29. Simply change:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{ article.url }}#{{ article.slug }} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;hellip; to&amp;hellip;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{{ article.slug }} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fixed!&lt;/p&gt;
&lt;p&gt;I haven&amp;rsquo;t submitted a pull request to Alexandre, because I suspect it&amp;rsquo;s intentional.&lt;/p&gt;
&lt;h2 id="getting-nginx-to-serve-tidy-urls"&gt;Getting Nginx to serve tidy urls:
&lt;/h2&gt;&lt;p&gt;By default, Pelican creates great urls like {server}/Ramblings/welcome-to-the-internet&lt;/p&gt;
&lt;p&gt;This is great, but it CREATES files like /var/www/Ramblings/welcome-to-the-internet.html&lt;/p&gt;
&lt;p&gt;Nginx by default doesn&amp;rsquo;t see &amp;ldquo;welcome-to-the-internet&amp;rdquo; and automatically serve &amp;ldquo;welcome-to-the-internet.html&amp;rdquo;. The lack of a file extention means that the .html file is fundamentally &lt;em&gt;a different file&lt;/em&gt;, so it returns a handy-dandy 404 error instead.&lt;/p&gt;
&lt;p&gt;To fix this, open /etc/nginx/sites-available/yoursite, and find:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;location / {
 try_files $uri $uri/ =404;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Change it to the following - note I&amp;rsquo;ve added $uri.htm and $uri.html, to inform Nginx that it should try appending .htm or .html onto the end of a uri if it can&amp;rsquo;t find the page:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;location / {
 try_files $uri.htm $uri.html $uri =404;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All done, happy tidy URLs!&lt;/p&gt;</description></item></channel></rss>