DEV Community

Justin Cooksey
Justin Cooksey

Posted on • Originally published at on

Publishing Pelican Created Site

This is the second part (see part 1 here) of my migrating a static web site over to Pelican Static Site Generator, after my inital posting Pelican Static Site Generator

Google Analytics

To transfer over Google Analytics web site code to the Pelican created site was as simple as adding it in to as a varible and done. This is all well docmented on the Pelican doumentation.

GOOGLE_ANALYTICS = your_site_code

Enter fullscreen mode Exit fullscreen mode

Hosting and Replacing on Netlify

As the GatsbyJS site was hosted on Netlify which also supports Python and Pelican builds rehosting on Netlify was relatively easy.

First though was getting the source repository ready. Starting with making sure the requirements.txt file exists, as Netfliy build process will be using this to install the required python libraries for the site. I generally keep this up to date as I work, but simply creating it again with the usual command is easy enough:

pip freeze > requirements.txt

Enter fullscreen mode Exit fullscreen mode

Then making sure the file has all the correct settings for the final published site. This was pretty much correct and needed only confirming that it had the correct variables in it for the final site. Overwriting the development variables stored in

A netfliy.toml file in the root of the repo will give Netlify the commands to build the site and location of the built site files to publish:

command = "pelican content -s"
publish = "output"

Enter fullscreen mode Exit fullscreen mode

also a block to specificy the page (HTML file) to display for a 404 page not found repsonse:

from = "/*"
to = "/404.html"
status = 404

Enter fullscreen mode Exit fullscreen mode

Linking in the new repo

After those things are all settled it is just a matter of linking the GitHub repo to the the Netlify site, and Netfliy will do the rest. Building the site and publishing it ready for use.

So is that it?

Well, while I have the Pelican built site now the active builder for the static pages on the site, I still have plenty to work on. Plenty to upgrade including the theme, which is still not quite right, and of course content on the site for other projects and well whatever else is happening in life......

Top comments (0)