<p>Nikola - The Static Web Site and Blog Generator - <a href="https://getnikola.com">https://getnikola.com</a></p>
 <p><strong>Note:</strong> Please see developer notes below</p>
 <p>What is it? A Static Website and Blog Generator based on Python.<br /> What is a Static Website Generator? It generates posts and pages via commands. You edit those posts and pages in a text editor, then run a command to build the site, and finally, deploy/upload the generated html etc files to your webhost.<br /> That sounds kinda old school are you sure thats web 3.0? Its old and new school. Nikola gives you CMS like features without the overhead of the database server and page rendering engine.<br /> How can I install it? Use PIP and follow the handbook on the getnikola.com website. NOTE: Python 2.6 or newer or Python 3.3 or newer is required</p><pre>
sudo pip install nikola
sudo pip install nikola[extras]
</pre><p>You should be good to go if you can enter nikola help in a terminal and get a list of nikola commands.<br /> Lets create our skeleton website:</p><pre>
nikola init mysite 
</pre><p>You will need to answer some questions now (NOTE a directory to cd into called mysite will be created if you issue mysite.. You should enter your domain name instead - mysite is just an example).<br /> The questions it asks will help populate the conf.py file in the mysite directory.</p><pre>
Site Title: 
Site Author:
Site Author Email:
Site Description:
Site URL:
Languages to support: (default en)
Time zone: 
Which comments system to use:
</pre><p>Once complete your site will be created and in the directory you named the site as - in my case, mysite.<br /> cd into that and take a look at the files with ls.<br /> you will have:</p>
 <ul>
  <li>conf.py - your configuration file</li>
  <li>files - where you will place images etc and reference them in blog posts and pages</li>
  <li>galleries - where you can serve up images in a gallery</li>
  <li>posts - where your blog posts go</li>
  <li>stories - where your pages go</li>
 </ul>
 <p>Lets create a blog post.</p><pre>
nikola new_post
</pre><p>Type in the title of your blog post and hit enter. I will use foobar in this example<br /> It will report the new post is in posts/foobar.rst<br /> fire up your text editor and edit that file.</p>
 <p>There is a header area at the top of the file - most of it is already filled in and you wont need to change it but you should add a Tag because you can see posts by Tag once the site is generated and it gives your readers a way to find all items on that subject. These are separated by commas so enter as many or few as you like. Enter a Description in the Description area.<br /> Now move into the Write your post here area and go to town - erase that or it shows up in your post.<br /> You should read the page on ReStructuredText here: <a href="https://getnikola.com/quickstart.html">https://getnikola.com/quickstart.html</a> but also just look at the source by clicking 'Source' on the getnikola website and you can see the markup they used. Some basics are</p><pre>
*word*
</pre> for italics, <pre>
**word**
</pre> for bold, a single * space item for bullet points and for hyperlinks <pre>
`Tree Brewing Co: &lt;https://treebeer.com/&gt;`_.
</pre> a Tree Brewing Co hyperlink which will bring you when clicked to treebeer.com. Lastly issue: <pre>
.. image:: /files/imagefilename.jpg
</pre> to point to an image file that you have placed into the files directory.<br /> Ok lets say you are done your post, save it and exit. Lets now build your site and fire up the built in webserver to display it. <pre>
nikola build
nikola serve -b
</pre><p>Your default web browser will launch and you will see your site with blog post. Savour the moment - you have just created your first blog post. Note all the generated files you would upload to your webhost are in the output folder.<br /> Ok so thats great but I want to add pages and have it in my navigation window Ok lets do that.</p><pre>
nikola new_post -p
</pre> Enter a name for it and press Enter. In my case I created MyPage <p>It tells you your page is in the stories directory and shows you how it named the file. In my case its mypage.rst<br /> Open that in a text editor and compose the page - save it when complete.<br /> So that would be great but its not showing up in your navigation yet. You need to put that in your conf.py file.<br /> Open conf.py in a text editor, look for NAVIGATION_LINKS. Observe how the existing pages are linked and follow that format. Here is how I would add mypage: (/stories/mypage.html, MyPage), any page you create will show up in stories so dont forget to put that in the path.</p><pre>
NAVIGATION_LINKS = {
    DEFAULT_LANG: (
        ("/archive.html", "Archive"),
        ("/categories/index.html", "Tags"),
        ("/rss.xml", "RSS feed"),
        ("/stories/mypage.html", "MyPage"),
    ),
}
</pre><p>Save that and rebuild your site.<br /> NOTE:: As of Today Nikola v7.0.1 requires a special command to include the new pages in navigation. This has been fixed in git but currently you must issue:</p><pre>
nikola build -a
nikola serve -b 
</pre><p>Now you are viewing it - nice work - you have a page now.<br /> This site seems a bit plain, how can I theme it? Glad that you asked - issue this command.</p><pre>
nikola bootswatch_theme -n custom_theme -s slate -p bootstrap3
</pre><p>Now you have set it to use the slate bootswatch theme. Review the bootswatch themes on: <a href="https://bootswatch.com/">https://bootswatch.com/</a><br /> In order to let Nikola know to use this new theme you need to edit the conf.py file and look for THEME and change the value from bootstrap3 to custom_theme.<br /> Now issue these commands at the command line to view the changes:</p><pre>
nikola build
nikola serve -b 
</pre><p>You can modify the themes to your liking and there is guidance on changing the theme on the nikola website.<br /> There are ways to depoly your site via rsync or ftp commands in the conf.py file. There are also other things you can set in the conf file such as google analytics, add an embeded duckduckgo or google search engine, specify options for the image galleries etc.<br /> More things you can do to spify up your posts / pages are to do with using shortcode like sytax for ReStructuredText. You can embed soundcloud, youtube videos etc - here is a list of these: <a href="https://getnikola.com/handbook.html#restructuredtext-extensions">https://getnikola.com/handbook.html#restructuredtext-extensions</a></p>
 <p>I hope this helps you get started on using Nikola and hope you enjoy using it as much as I do. If you have questions or comments, find me in the oggcastplanet.net irc chat room on freenode, or go to <a href="https://stevebaer.com">https://stevebaer.com</a> click Tags and click HPR and leave a comment on this episodes blog post. Until next time, Cheers!</p>
 <h2>Corrections to this episode provided by Chris Warrick</h2>
 <p><a href="https://stevebaer.com/posts/hpr-episode-on-using-the-static-web-site-and-blog-generator-called-nikola.html">https://stevebaer.com/posts/hpr-episode-on-using-the-static-web-site-and-blog-generator-called-nikola.html</a></p>
 <h3>Some small corrections:</h3>
 <ol>
  <li>it is recommended to use a virtualenv, `sudo pip` can be dangerous</li>
  <li>`pip install nikola[extras]` is enough, no need to do both steps</li>
  <li>new pages can be created with `nikola new_page`, too (both ways are equally supported)</li>
  <li>
   <del>missing quotes around "MyPage" in example navbar code</del><em>Fixed</em></li>
  <li>you can get rid of /stories/ if you change PAGES[*][1] from "stories" to an empty string.</li>
  <li>bootswatch themes are not everything, there is also install_theme that uses a more varied collection from https://themes.getnikola.com/</li>
 </ol>