Source

tinkerer / blog / doc / deploying.rst

Full commit

Deploying

Tinkerer generates a static website under blog/html. The files can be uploaded anywhere. An option is to host your blog on Bitbucket.

Hosting on Bitbucket

Create a repository named $(USERNAME).bitbucket.org where $(USERNAME) is your Bitbucket username, for example johndoe.bitbucket.org. If you create such a repository, when accessing http://johndoe.bitbucket.org, Bitbucket will automatically serve the index.html found under the root of the repository. The repository name must include .bitbucket.org, so in the example above the actual repository URL would be http://bitbucket.org/johndoe/johndoe.bitbucket.org/.

You have two options:

Upload HTML only

Commit the content of your blog's blog/html directory to the repository. The index.html file generated by Tinkerer is the front page of your blog.

Note

Make sure to update the website variable in conf.py to http://johndoe.bitbucket.org/ so the RSS feed can properly link your posts.

Upload both HTML and sources

Commit your whole blog to the repository, including files in the root directory and source. Tinkerer generates an index.html file in the blog's root which redirects to blog/html/index.html to enable this scenario.

Note

Make sure to update the website variable in conf.py to http://johndoe.bitbucket.org/blog/html/ so the RSS feed can properly link your posts. Note the trailing blog/html - the website variable must point to the root of your blog's build directory, not root directory.

Copying extra files to the html output directory

Files placed in an folder named _copy will be automatically copied to the html output directory.

This could be useful for an .htaccess file, an robots.txt file or an extra favicon.ico etc.

Creating custom 404 and 403 error pages

If your webserver supports .htaccess files you can create these pages by placing an .htaccess file under _copy/.htaccess with the following content:

ErrorDocument 404 http://www.yoursite.com/404.html
ErrorDocument 403 http://www.yoursite.com/403.html
Options -Indexes

Add an file 404.rst to the document root:

The URL you requested was not found.
====================================

.. comments::

Your own text.

Add an file 403.rst to the document root:

403 Permission Denied
=====================

.. comments::

Your own text.

And add these two pages to the master.rst file:

Sitemap
=======

.. toctree::
  :hidden:

  404.rst
  403.rst

.. toctree::
  :maxdepth: 1

  2012/04/21/a_blog_post
  pages/about

Adding custom analytics code

If you don't want to use Google Analytics and for example Piwik you can add custom JavaScript code by placing an file named page.html under _templates/page.html:

{% extends "!page.html" %}

{% block footer %}
    {{ super() }}
    {% include "../_static/piwik.js" %}
{% endblock %}

And the analytics code inside _static/piwik.js:

<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.yoursite.com/piwik/" : "http://piwik.yoursite.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://piwik.yoursite.com/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

Back to :ref:`tinkerer_reference`.