What is the difference between pelicanconf and publishconf when using Pelican

I used the quick start pelican to create a static website, and this is due to the default pelicanconf and publishconf. I have a GOOGLE_ANALYTICS variable in my publishconf, but when I publish my static page to Github Pages using this snippet:

<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS }}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> 

_setAccount becomes an empty string.

Should I move GOOGLE_ANALYTICS from publishconf to pelicanconf? What is the difference between the two?

+7
python github-pages pelican
source share
2 answers

As the person who first bifurcated the Pelican settings file, I recommend thinking of two main operating modes: local deployment of development and production (i.e. pelicanconf.py and publishconf.py , respectively).

Moving GOOGLE_ANALYTICS from publishconf.py to pelicanconf.py not recommended. When developing locally, settings for things like Google Analytics and Disqus are deliberately excluded from pelicanconf.py by design. Including these settings in local testing can have adverse consequences: inaccurate site statistics, false comment streams, and other unforeseen side effects.

When it's time to publish your site, then of course you want to enable these settings. The way to do this is to ensure that your publishconf.py to the time of publication:

 pelican content -s publishconf.py 

If you are using the Fabric or Make Automation framework that wraps the pelican command, you can use:

 fab publish 

... or...

 make publish 

I recommend a close look at how you publish your site, ensuring that the appropriate settings file is used during the local development and production deployment, respectively.

+14
source share

What you defined in publishconf.py overrides the same definitions in pelicanconf.py .
But note that publishconf.py used only in two cases:

  • When you use make publish (or one of the other make commands) to create your site.
  • If you explicitly specify it as the configuration file to be used (i.e. pelican -s publishconf.py content_dir ).

So, if you create your site using the pelican and do not explicitly specify your configuration file, only pelicanconf.py will be used; so you need the GOOGLE_ANALYTICS variable.

+3
source share

All Articles