{"id":9328,"date":"2023-05-23T11:17:42","date_gmt":"2023-05-23T09:17:42","guid":{"rendered":"https:\/\/www.main-vision.com\/richard\/blog\/?p=9328"},"modified":"2023-05-23T11:22:08","modified_gmt":"2023-05-23T09:22:08","slug":"playing-with-pelican-a-static-blog-website","status":"publish","type":"post","link":"https:\/\/www.main-vision.com\/richard\/blog\/playing-with-pelican-a-static-blog-website\/","title":{"rendered":"Playing With Pelican &#8211; A Static Blog Website"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p>When looking at Codeberg as a European alternative to github I came across mentions of Pelican, a static blog generator. Yesterday I spent several hours setting it up and playing. Whilst playing with it I saw some opportunities.&nbsp;<\/p>\n\n\n\n<p>By default Pelican is designed to have one category per blog post. For small websites this is fine. It encourages people to focus on three to five topics, and ensure that each topic is clearly visible in the nav bar at the top of the page.&nbsp;<\/p>\n\n\n\n<p>When I imported two different wordpress blogs I had success is importing the blog posts, but a failure when it came to the nav bar.&nbsp;<\/p>\n\n\n\n<p><strong>How Does Pelican Work<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/docs.getpelican.com\/en\/stable\/content.html\" data-type=\"URL\" data-id=\"https:\/\/docs.getpelican.com\/en\/stable\/content.html\">Pelican<\/a> can use html, reStructuredText or markdown. It wants to know the date, tags, category, slug, authors, summary and more for each page. Once a page has this information, as well as some content you type \u201cpelican content\u201d and it will generate the static website for you. You can then test the site with pelican listen and check that the website is displaying and working as desired.\u00a0<\/p>\n\n\n\n<p><strong>Categories<\/strong><\/p>\n\n\n\n<p>If I wrote a blog post about hiking in Vaud, Switzerland I would have that blog in \u201chiking\u201d, \u201cSwitzerland\u201d and \u201cVaud\u201d. Pelican combined the three categories and created a nav page. The result is that I had a bloated nav bar.&nbsp;<\/p>\n\n\n\n<p>When I enquired about parsing the categories I was told that Pelican wanted to have one category per page, intentionally. They also told me that a plugin allows you to create <a href=\"https:\/\/github.com\/pelican-plugins\/more-categories\" data-type=\"URL\" data-id=\"https:\/\/github.com\/pelican-plugins\/more-categories\">more categories<\/a>.\u00a0 This plugin is quick and easy to install and implement.\u00a0<\/p>\n\n\n\n<p><strong>More Categories<\/strong><\/p>\n\n\n\n<p>With <a href=\"https:\/\/github.com\/pelican-plugins\/more-categories\" data-type=\"URL\" data-id=\"https:\/\/github.com\/pelican-plugins\/more-categories\">More Categories<\/a> you can add several categories per blog post, but you can also add a hierarchy. If you write a post about hiking in Vaud, Switzerland, you can have hiking, vaud, switzerland, as a flat hierarchy. You can also have \u201csports\/hiking\u201d and \u201cSwitzerland\/Vaud\u201d as subcategories. This opens up the possibility of creating a nuanced static website.\u00a0<\/p>\n\n\n\n<p><strong>Importing a Website<\/strong><\/p>\n\n\n\n<p>You can <a href=\"https:\/\/docs.getpelican.com\/en\/latest\/importer.html\" data-type=\"URL\" data-id=\"https:\/\/docs.getpelican.com\/en\/latest\/importer.html\">import content<\/a> from another source by using pelican import. You can choose from Blogger, WordPress etc. I experimented with importing from WordPress and it\u00a0 worked well, except for the issues I mentioned earlier.\u00a0<\/p>\n\n\n\n<p><strong>Streamlining an HTML Site<\/strong><\/p>\n\n\n\n<p>My website is split into three parts<\/p>\n\n\n\n<p>\u2022 <a href=\"https:\/\/www.main-vision.com\/\">The legacy HTML section<\/a><\/p>\n\n\n\n<p>\u2022 the main blog<\/p>\n\n\n\n<p>\u2022 <a href=\"https:\/\/www.main-vision.com\/richard-photos\/\" data-type=\"URL\" data-id=\"https:\/\/www.main-vision.com\/richard-photos\/\">the photo blog<\/a><\/p>\n\n\n\n<p>After the two tests I ran yesterday I came to the conclusion that, for now, I will keep using wordpress for the blogs. The reason I think Pelican is interesting for me is that it can read html and the legacy part of my website is html. The challenge with legacy code is keeping the navigation and other parts up to date each time you make small changes. With Pelican I hope to delegate navigation creation. By ensuring that each page has the correct meta data in the header I can then get Pelican to regenerate the website with a navigation that is easier to keep up to date.&nbsp;<\/p>\n\n\n\n<p><strong>Measuring Success<\/strong><\/p>\n\n\n\n<p>If I am successful then I will have the website imported into Pelican and I will have a geography, environmental systems, Ancient Rome, and other sections and one or two sections will have themes that are specific to them.&nbsp;<\/p>\n\n\n\n<p><a href=\"https:\/\/wiki.python.org\/moin\/StaticSiteGenerator\" data-type=\"URL\" data-id=\"https:\/\/wiki.python.org\/moin\/StaticSiteGenerator\">List of other Python Static Website Generators<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>When looking at Codeberg as a European alternative to github I came across mentions of Pelican, a static blog generator. Yesterday I spent several hours setting it up and playing. Whilst playing with it I saw some opportunities.&nbsp; By default Pelican is designed to have one category per blog post. For small websites this is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9070,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[1094,5189,4259,5188],"class_list":["post-9328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website-news","tag-learning","tag-pelican","tag-python","tag-static-generators"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/9328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/comments?post=9328"}],"version-history":[{"count":3,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/9328\/revisions"}],"predecessor-version":[{"id":9331,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/posts\/9328\/revisions\/9331"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/media\/9070"}],"wp:attachment":[{"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/media?parent=9328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/categories?post=9328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.main-vision.com\/richard\/blog\/wp-json\/wp\/v2\/tags?post=9328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}