A new Riff-radio.org site with a static approach.

creating-a-theme.html 128KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Creating a Theme | Riff</title>
  7. <link href="../assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
  8. <link rel="alternate" type="application/rss+xml" title="RSS" href="../rss.xml">
  9. <link rel="canonical" href="http://media.pagelibre.org/riff/site/pages/creating-a-theme.html">
  10. <link rel="icon" href="../favicon.ico" sizes="16x16">
  11. <!--[if lt IE 9]><script src="../assets/js/html5.js"></script><![endif]--><meta name="author" content="Riff">
  12. <meta property="og:site_name" content="Riff">
  13. <meta property="og:title" content="Creating a Theme">
  14. <meta property="og:url" content="http://media.pagelibre.org/riff/site/pages/creating-a-theme.html">
  15. <meta property="og:description" content="Nikola is a static site and blog generator. So is Jekyll. While I like what we have done with Nikola,
  16. I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.
  17. This docum">
  18. <meta property="og:type" content="article">
  19. <meta property="article:published_time" content="2015-05-28T18:46:48Z">
  20. </head>
  21. <body>
  22. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  23. <!-- Menubar -->
  24. <div class="blog-masthead">
  25. <div class="container">
  26. <!-- This keeps the margins nice -->
  27. <nav class="blog-nav" role="navigation"><a href="../index.html" class="blog-nav-item">Accueil</a>
  28. <a href="about.html" class="blog-nav-item">About Riff</a>
  29. <a href="../rss.xml" class="blog-nav-item">RSS feed</a>
  30. </nav>
  31. </div>
  32. <!-- /.container -->
  33. </div>
  34. <!-- End of Menubar -->
  35. <div class="container" id="content" role="main">
  36. <div class="body-content">
  37. <div class="blog-header">
  38. <h1 class="blog-title">
  39. <a href="http://media.pagelibre.org/riff/site/">
  40. <span id="blog-title">Riff</span>
  41. </a>
  42. </h1>
  43. <p class="lead blog-description">Riff la radio rock</p>
  44. </div>
  45. <!--Body content-->
  46. <div class="row">
  47. <div class="col-sm-8 blog-main">
  48. <article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h2 class="p-name entry-title blog-post-title" itemprop="headline name"><a href="#" class="u-url">Creating a Theme</a></h2>
  49. </header><div class="e-content entry-content" itemprop="articleBody text">
  50. <p>Nikola is a static site and blog generator. So is Jekyll. While I like what we have done with Nikola,
  51. I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.</p>
  52. <p>This document is an attempt at making it easier for 3rd parties (that means <em>you</em> people! ;-) to
  53. create themes. Since I <strong>suck</strong> at designing websites, I asked for opinions on themes to port,
  54. and got some feedback. Since this is <strong>Not So Hard™</strong>, I will try to make time to port a few
  55. and see what happens.</p>
  56. <p>If you are looking for a reference, check out <a class="reference external" href="theming.html">Theming reference</a> and <a class="reference external" href="https://getnikola.com/template-variables.html">Template variables</a>.</p>
  57. <p>Today’s theme is <a class="reference external" href="https://github.com/poole/lanyon">Lanyon</a> which is written by <a class="reference external" href="https://twitter.com/mdo">@mdo</a>
  58. and released under a MIT license, which is liberal enough.</p>
  59. <p>So, let’s get started.</p>
  60. <section id="checking-it-out"><h2>Checking It Out</h2>
  61. <p>The first step in porting a theme is making the original theme work. Lanyon is awesome in that its
  62. <a class="reference external" href="https://github.com/poole/lanyon">GitHub project</a> is a full site!</p>
  63. <p>So:</p>
  64. <pre class="literal-block"># Get jekyll
  65. sudo apt-get install jekyll
  66. # Get Lanyon
  67. git clone git@github.com:poole/lanyon.git
  68. # Build it
  69. cd lanyon &amp;&amp; jekyll build
  70. # Look at it
  71. jekyll serve &amp; google-chrome http://localhost:4000</pre>
  72. <p>If you <strong>do not want to install Jekyll</strong>, you can also see it in action at <a class="reference external" href="https://lanyon.getpoole.com/">https://lanyon.getpoole.com/</a></p>
  73. <p>Some things jump to my mind:</p>
  74. <ol class="arabic simple">
  75. <li><p>This is one fine looking theme</p></li>
  76. <li><p>Very clear and readable</p></li>
  77. <li><p>Nice hidden navigation-thingy</p></li>
  78. </ol>
  79. <p>Also, from looking at <a class="reference external" href="https://github.com/poole/lanyon/blob/master/README.md">the project’s README</a>
  80. it supports some nice configuration options:</p>
  81. <ol class="arabic simple">
  82. <li><p>Color schemes</p></li>
  83. <li><p>Reverse layout</p></li>
  84. <li><p>Sidebar overlay instead of push</p></li>
  85. <li><p>Open the sidebar by default, or on a per-page basis by using its metadata</p></li>
  86. </ol>
  87. <p>Let’s try to make all those nice things survive the porting.</p>
  88. </section><section id="starting-from-somewhere"><h2>Starting From Somewhere</h2>
  89. <p>Nikola has a nice, clean, base theme from which you can start when writing your own theme.
  90. Why start from that instead of from a clean slate? Because theme inheritance is going to save you a ton of work,
  91. that’s why. If you start from scratch you won’t be able to build <strong>anything</strong> until you have a bunch of
  92. templates written. Starting from base, you just need to hack on the things you <strong>need</strong> to change.</p>
  93. <p>First, we create a site with some content in it. We’ll use the <code class="docutils literal">nikola init</code> wizard (with the <code class="docutils literal"><span class="pre">--demo</span></code> option) for that:</p>
  94. <pre class="literal-block">$ nikola init --demo lanyon-port
  95. Creating Nikola Site
  96. ====================
  97. This is Nikola v7.8.0. We will now ask you a few easy questions about your new site.
  98. If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.
  99. --- Questions about the site ---
  100. Site title [My Nikola Site]:
  101. Site author [Nikola Tesla]:
  102. Site author's e-mail [n.tesla@example.com]:
  103. Site description [This is a demo site for Nikola.]:
  104. Site URL [https://example.com/]:
  105. --- Questions about languages and locales ---
  106. We will now ask you to provide the list of languages you want to use.
  107. Please list all the desired languages, comma-separated, using ISO 639-1 codes. The first language will be used as the default.
  108. Type '?' (a question mark, sans quotes) to list available languages.
  109. Language(s) to use [en]:
  110. Please choose the correct time zone for your blog. Nikola uses the tz database.
  111. You can find your time zone here:
  112. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  113. Time zone [UTC]:
  114. Current time in UTC: 16:02:07
  115. Use this time zone? [Y/n]
  116. --- Questions about comments ---
  117. You can configure comments now. Type '?' (a question mark, sans quotes) to list available comment systems. If you do not want any comments, just leave the field blank.
  118. Comment system:
  119. That's it, Nikola is now configured. Make sure to edit conf.py to your liking.
  120. If you are looking for themes and addons, check out https://themes.getnikola.com/ and https://plugins.getnikola.com/.
  121. Have fun!
  122. [2015-05-28T16:02:08Z] INFO: init: A new site with example data has been created at lanyon-port.
  123. [2015-05-28T16:02:08Z] INFO: init: See README.txt in that folder for more information.</pre>
  124. <p>Then, we create an empty theme inheriting from base. This theme will use Mako templates. If you prefer Jinja2,
  125. then you should use <code class="docutils literal"><span class="pre">base-jinja</span></code> as a parent and <code class="docutils literal">jinja</code> as engine instead:</p>
  126. <pre class="literal-block">$ cd lanyon-port/
  127. $ nikola theme -n lanyon --parent base --engine mako</pre>
  128. <p>Edit <code class="docutils literal">conf.py</code> and set <code class="docutils literal">THEME = 'lanyon'</code>. Also set <code class="docutils literal">USE_BUNDLES = False</code> (just do it for now, we’ll get to bundles later).
  129. Also, if you intend to publish your theme on the Index, or want to use it with older versions (v7.8.5 or older), use the <code class="docutils literal"><span class="pre">--legacy-meta</span></code> option for <code class="docutils literal">nikola theme <span class="pre">-n</span></code>.</p>
  130. <p>You can now build that site using <code class="docutils literal">nikola build</code> and it will look like this:</p>
  131. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-0.png"><img alt="https://getnikola.com/images/lanyon-0.thumbnail.png" src="https://getnikola.com/images/lanyon-0.thumbnail.png"></a>
  132. <figcaption><p>This is just the base theme.</p>
  133. </figcaption></figure></section><section id="basic-css"><h2>Basic CSS</h2>
  134. <p>The next step is to know exactly how Lanyon’s pages work. To do this, we read its HTML.
  135. First let’s look at the head element:</p>
  136. <pre class="code html"><a name="rest_code_aaccd00a36264f57b74893d4eb903571-1"></a><span class="cp">&lt;!DOCTYPE html&gt;</span>
  137. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-2"></a><span class="p">&lt;</span><span class="nt">html</span> <span class="na">xmlns</span><span class="o">=</span><span class="s">"http://www.w3.org/1999/xhtml"</span> <span class="na">xml:lang</span><span class="o">=</span><span class="s">"en"</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en-us"</span><span class="p">&gt;</span>
  138. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-3"></a>
  139. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-4"></a><span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  140. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-5"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://gmpg.org/xfn/11"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"profile"</span><span class="p">&gt;</span>
  141. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-6"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"content-type"</span> <span class="na">content</span><span class="o">=</span><span class="s">"text/html; charset=utf-8"</span><span class="p">&gt;</span>
  142. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-7"></a>
  143. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-8"></a><span class="c">&lt;!-- Enable responsiveness on mobile devices--&gt;</span>
  144. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-9"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"viewport"</span> <span class="na">content</span><span class="o">=</span><span class="s">"width=device-width, initial-scale=1.0, maximum-scale=1"</span><span class="p">&gt;</span>
  145. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-10"></a>
  146. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-11"></a><span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span>
  147. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-12"></a> Lanyon <span class="ni">&amp;middot;</span> A Jekyll theme
  148. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-13"></a><span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
  149. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-14"></a>
  150. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-15"></a><span class="c">&lt;!-- CSS --&gt;</span>
  151. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-16"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/public/css/poole.css"</span><span class="p">&gt;</span>
  152. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-17"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/public/css/syntax.css"</span><span class="p">&gt;</span>
  153. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-18"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/public/css/lanyon.css"</span><span class="p">&gt;</span>
  154. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-19"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400"</span><span class="p">&gt;</span>
  155. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-20"></a>
  156. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-21"></a><span class="c">&lt;!-- Icons --&gt;</span>
  157. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-22"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"apple-touch-icon-precomposed"</span> <span class="na">sizes</span><span class="o">=</span><span class="s">"144x144"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/public/apple-touch-icon-144-precomposed.thumbnail.png"</span><span class="p">&gt;</span>
  158. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-23"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"shortcut icon"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/public/favicon.ico"</span><span class="p">&gt;</span>
  159. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-24"></a>
  160. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-25"></a><span class="c">&lt;!-- RSS --&gt;</span>
  161. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-26"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"alternate"</span> <span class="na">type</span><span class="o">=</span><span class="s">"application/rss+xml"</span> <span class="na">title</span><span class="o">=</span><span class="s">"RSS"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/atom.xml"</span><span class="p">&gt;</span>
  162. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-27"></a>
  163. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-28"></a><span class="c">&lt;!-- Google Analytics --&gt;</span>
  164. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-29"></a>[...]
  165. <a name="rest_code_aaccd00a36264f57b74893d4eb903571-30"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  166. </pre>
  167. <p>The interesting part there is that it loads a few CSS files. If you check the source of your Nikola site, you will
  168. see something fairly similar:</p>
  169. <pre class="code html"><a name="rest_code_990036230fdd4f33818ff702e2f5ec35-1"></a><span class="cp">&lt;!DOCTYPE html&gt;</span>
  170. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-2"></a><span class="p">&lt;</span><span class="nt">html</span> <span class="na">prefix</span><span class="o">=</span><span class="s">"og: http://ogp.me/ns# article: http://ogp.me/ns/article# "</span> <span class="na">vocab</span><span class="o">=</span><span class="s">"http://ogp.me/ns"</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">&gt;</span>
  171. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-3"></a><span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  172. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-4"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">&gt;</span>
  173. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-5"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"description"</span> <span class="na">content</span><span class="o">=</span><span class="s">"This is a demo site for Nikola."</span><span class="p">&gt;</span>
  174. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-6"></a><span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"viewport"</span> <span class="na">content</span><span class="o">=</span><span class="s">"width=device-width"</span><span class="p">&gt;</span>
  175. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-7"></a><span class="p">&lt;</span><span class="nt">title</span><span class="p">&gt;</span>My Nikola Site | My Nikola Site<span class="p">&lt;/</span><span class="nt">title</span><span class="p">&gt;</span>
  176. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-8"></a>
  177. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-9"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"assets/css/rst_base.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  178. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-10"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"assets/css/code.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  179. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-11"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"assets/css/theme.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  180. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-12"></a>
  181. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-13"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"alternate"</span> <span class="na">type</span><span class="o">=</span><span class="s">"application/rss+xml"</span> <span class="na">title</span><span class="o">=</span><span class="s">"RSS"</span> <span class="na">href</span><span class="o">=</span><span class="s">"rss.xml"</span><span class="p">&gt;</span>
  182. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-14"></a><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"canonical"</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://example.com/index.html"</span><span class="p">&gt;</span>
  183. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-15"></a><span class="c">&lt;!--[if lt IE 9]&gt;&lt;script src="assets/js/html5.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;</span><span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"prefetch"</span> <span class="na">href</span><span class="o">=</span><span class="s">"posts/welcome-to-nikola.html"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/html"</span><span class="p">&gt;</span>
  184. <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-16"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  185. </pre>
  186. <p>Luckily, since this is all under a very liberal license, we can just copy these CSS files into
  187. Nikola, adapting the paths a little so that they follow our conventions:</p>
  188. <pre class="literal-block">$ mkdir -p themes/lanyon/assets/css
  189. $ cp ../lanyon/public/css/poole.css themes/lanyon/assets/css/
  190. $ cp ../lanyon/public/css/lanyon.css themes/lanyon/assets/css/</pre>
  191. <p>Notice I am <em>not</em> copying <code class="docutils literal">syntax.css</code>? That’s because Nikola handles that styles for syntax highlighting
  192. in a particular way, using a setting called <code class="docutils literal">CODE_COLOR_SCHEME</code> where you can configure
  193. what color scheme the syntax highlighter uses. You can use your own <code class="docutils literal">assets/css/code.css</code> if you
  194. don’t like the provided ones.</p>
  195. <p>Nikola <strong>requires</strong> <code class="docutils literal">assets/css/rst_base.css</code> and <code class="docutils literal">assets/css/code.css</code> to function properly.
  196. We will also add themes for Jupyter (<code class="docutils literal">assets/css/ipython.min.css</code>
  197. and <code class="docutils literal">assets/css/nikola_ipython.css</code>) into the template; note that they are
  198. activated only if you configured your <code class="docutils literal">POSTS</code>/<code class="docutils literal">PAGES</code> with ipynb support.
  199. There’s also <code class="docutils literal">assets/css/nikola_rst.css</code>, which adds Bootstrap 3-style reST notes etc.</p>
  200. <p>But how do I tell <strong>our</strong> lanyon theme to use those CSS files instead of whatever it’s using now?
  201. By giving our theme its own base_helper.tmpl.</p>
  202. <p>That file is a <strong>template</strong> used to generate parts of the pages. It’s large and
  203. complicated but we don’t need to change a lot of it. First, make a copy in your
  204. theme (note this command requires setting your <code class="docutils literal">THEME</code> in <code class="docutils literal">conf.py</code> to
  205. <code class="docutils literal">lanyon</code>):</p>
  206. <pre class="literal-block">$ nikola theme -c base_helper.tmpl</pre>
  207. <p>The part we want to change is this:</p>
  208. <pre class="code html+mako"><a name="rest_code_adacc386e77a4a0ca76f3f5965909385-1"></a><span class="cp">&lt;%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_stylesheets()"</span><span class="cp">&gt;</span>
  209. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-2"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">use_bundles</span><span class="p">:</span>
  210. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-3"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">use_cdn</span><span class="p">:</span>
  211. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-4"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/all.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  212. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-5"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  213. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-6"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/all-nocdn.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  214. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-7"></a> <span class="cp">%</span><span class="k">endif</span>
  215. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-8"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  216. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-9"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/rst_base.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  217. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-10"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/nikola_rst.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  218. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-11"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/code.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  219. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-12"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/theme.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  220. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-13"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">has_custom_css</span><span class="p">:</span>
  221. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-14"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/custom.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  222. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-15"></a> <span class="cp">%</span><span class="k">endif</span>
  223. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-16"></a> <span class="cp">%</span><span class="k">endif</span>
  224. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-17"></a> <span class="cp">%</span> <span class="k">if</span> <span class="n">needs_ipython_css</span><span class="p">:</span>
  225. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-18"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/ipython.min.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  226. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-19"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/nikola_ipython.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  227. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-20"></a> <span class="cp">%</span><span class="k"> endif</span>
  228. <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-21"></a><span class="cp">&lt;/%</span><span class="nb">def</span><span class="cp">&gt;</span>
  229. </pre>
  230. <p>And we will change it so it uses the lanyon styles instead of theme.css (again, ignore the bundles for now!):</p>
  231. <pre class="code html+mako"><a name="rest_code_481d3ff311a64503aa44d20cc132c419-1"></a><span class="cp">&lt;%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_stylesheets()"</span><span class="cp">&gt;</span>
  232. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-2"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">use_bundles</span><span class="p">:</span>
  233. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-3"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/all.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  234. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-4"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  235. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-5"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/rst_base.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  236. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-6"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/nikola_rst.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  237. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-7"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/poole.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  238. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-8"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/lanyon.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  239. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-9"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/code.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  240. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-10"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">has_custom_css</span><span class="p">:</span>
  241. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-11"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/custom.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  242. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-12"></a> <span class="cp">%</span><span class="k">endif</span>
  243. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-13"></a> <span class="cp">%</span><span class="k">endif</span>
  244. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-14"></a> <span class="cp">%</span> <span class="k">if</span> <span class="n">needs_ipython_css</span><span class="p">:</span>
  245. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-15"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/ipython.min.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  246. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-16"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">href</span><span class="o">=</span><span class="s">"/assets/css/nikola_ipython.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">&gt;</span>
  247. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-17"></a> <span class="cp">%</span><span class="k"> endif</span>
  248. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-18"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400"</span><span class="p">&gt;</span>
  249. <a name="rest_code_481d3ff311a64503aa44d20cc132c419-19"></a><span class="cp">&lt;/%</span><span class="nb">def</span><span class="cp">&gt;</span>
  250. </pre>
  251. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-1.png"><img alt="https://getnikola.com/images/lanyon-1.thumbnail.png" src="https://getnikola.com/images/lanyon-1.thumbnail.png"></a>
  252. <figcaption><p>You may say this looks like crap. Don’t worry, we are just starting :-)</p>
  253. </figcaption></figure></section><section id="page-layout"><h2>Page Layout</h2>
  254. <p>This is trickier but should be no problem for people with a basic understanding of HTML and a desire to make a theme!</p>
  255. <p>Lanyon’s content is split in two parts: a sidebar and the rest. The sidebar looks like this (shortened for comprehension):</p>
  256. <pre class="code html"><a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-1"></a><span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  257. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-2"></a><span class="c">&lt;!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular</span>
  258. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-3"></a><span class="c"> styles, `#sidebar-checkbox` for behavior. --&gt;</span>
  259. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-4"></a><span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"checkbox"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span> <span class="na">id</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span><span class="p">&gt;</span>
  260. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-5"></a>
  261. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-6"></a><span class="c">&lt;!-- Toggleable sidebar --&gt;</span>
  262. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-7"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar"</span> <span class="na">id</span><span class="o">=</span><span class="s">"sidebar"</span><span class="p">&gt;</span>
  263. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-8"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-item"</span><span class="p">&gt;</span>
  264. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-9"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>A reserved <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://jekyllrb.com"</span> <span class="na">target</span><span class="o">=</span><span class="s">"_blank"</span><span class="p">&gt;</span>Jekyll<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> theme that places the utmost gravity on content with a hidden drawer. Made by <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://twitter.com/mdo"</span> <span class="na">target</span><span class="o">=</span><span class="s">"_blank"</span><span class="p">&gt;</span>@mdo<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>.<span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  265. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-10"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  266. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-11"></a>
  267. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-12"></a> <span class="p">&lt;</span><span class="nt">nav</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav"</span><span class="p">&gt;</span>
  268. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-13"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav-item active"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/"</span><span class="p">&gt;</span>Home<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  269. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-14"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav-item"</span> <span class="na">href</span><span class="o">=</span><span class="s">"/about/"</span><span class="p">&gt;</span>About<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  270. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-15"></a> [...]
  271. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-16"></a> <span class="p">&lt;/</span><span class="nt">nav</span><span class="p">&gt;</span>
  272. <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-17"></a><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  273. </pre>
  274. <p>So, a plain body, with an input element that controls the sidebar, a div which is the sidebar itself.
  275. Inside that, div.sidebar-item for items, and a nav with "navigational links". This is followed by the "masthead" and
  276. the content itself, which we will look at in a bit.</p>
  277. <p>If we look for the equivalent code in Nikola’s side, we see this:</p>
  278. <pre class="code html"><a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-1"></a><span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  279. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-2"></a><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"#content"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sr-only sr-only-focusable"</span><span class="p">&gt;</span>Skip to main content<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  280. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-3"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"container"</span><span class="p">&gt;</span>
  281. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-4"></a><span class="p">&lt;</span><span class="nt">header</span> <span class="na">id</span><span class="o">=</span><span class="s">"header"</span> <span class="na">role</span><span class="o">=</span><span class="s">"banner"</span><span class="p">&gt;</span>
  282. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-5"></a><span class="p">&lt;</span><span class="nt">h1</span> <span class="na">id</span><span class="o">=</span><span class="s">"brand"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://example.com/"</span> <span class="na">title</span><span class="o">=</span><span class="s">"My Nikola Site"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"home"</span><span class="p">&gt;</span> <span class="p">&lt;</span><span class="nt">span</span> <span class="na">id</span><span class="o">=</span><span class="s">"blog-title"</span><span class="p">&gt;</span>My Nikola Site<span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;</span> <span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
  283. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-6"></a><span class="p">&lt;</span><span class="nt">nav</span> <span class="na">id</span><span class="o">=</span><span class="s">"menu"</span> <span class="na">role</span><span class="o">=</span><span class="s">"navigation"</span><span class="p">&gt;&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
  284. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-7"></a><span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"../archive.html"</span><span class="p">&gt;</span>Archive<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
  285. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-8"></a> <span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"../categories/index.html"</span><span class="p">&gt;</span>Tags<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
  286. <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-9"></a> <span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"../rss.xml"</span><span class="p">&gt;</span>RSS feed<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
  287. </pre>
  288. <p>So Nikola has the "masthead" above the nav element, and uses list elements in nav instead of bare links.
  289. Not all that different is it?</p>
  290. <p>Let’s make it lanyon-like! We will need 2 more templates: <a class="reference external" href="https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base.tmpl">base.tmpl</a> and <a class="reference external" href="https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base_header.tmpl">base_header.tmpl</a>. Get them and put them in your <code class="docutils literal">themes/lanyon/templates</code> folder.</p>
  291. <p>Let’s look at <code class="docutils literal">base.tmpl</code> first. It’s short and nice, it looks like a webpage without
  292. all the interesting stuff:</p>
  293. <pre class="code html+mako"><a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
  294. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-2"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"base"</span> <span class="na">file=</span><span class="s">"base_helper.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  295. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-3"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"header"</span> <span class="na">file=</span><span class="s">"base_header.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  296. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-4"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"footer"</span> <span class="na">file=</span><span class="s">"base_footer.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  297. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-5"></a><span class="cp">${</span><span class="n">set_locale</span><span class="p">(</span><span class="n">lang</span><span class="p">)</span><span class="cp">}</span>
  298. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-6"></a><span class="cp">${</span><span class="n">base</span><span class="o">.</span><span class="n">html_headstart</span><span class="p">()</span><span class="cp">}</span>
  299. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-7"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">&gt;</span>
  300. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-8"></a><span class="cp">### Leave this block alone.</span>
  301. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-9"></a><span class="cp">&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  302. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-10"></a><span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'extra_head'</span><span class="p">]()</span><span class="cp">}</span>
  303. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-11"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  304. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-12"></a><span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  305. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-13"></a><span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"#content"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sr-only sr-only-focusable"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">messages</span><span class="p">(</span><span class="s2">"Skip to main content"</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  306. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-14"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"container"</span><span class="p">&gt;</span>
  307. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-15"></a> <span class="cp">${</span><span class="n">header</span><span class="o">.</span><span class="n">html_header</span><span class="p">()</span><span class="cp">}</span>
  308. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-16"></a> <span class="p">&lt;</span><span class="nt">main</span> <span class="na">id</span><span class="o">=</span><span class="s">"content"</span> <span class="na">role</span><span class="o">=</span><span class="s">"main"</span><span class="p">&gt;</span>
  309. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-17"></a> <span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">&gt;&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  310. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-18"></a> <span class="p">&lt;/</span><span class="nt">main</span><span class="p">&gt;</span>
  311. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-19"></a> <span class="cp">${</span><span class="n">footer</span><span class="o">.</span><span class="n">html_footer</span><span class="p">()</span><span class="cp">}</span>
  312. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-20"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  313. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-21"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
  314. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-22"></a> <span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'body_end'</span><span class="p">]()</span><span class="cp">}</span>
  315. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-23"></a> <span class="cp">${</span><span class="n">base</span><span class="o">.</span><span class="n">late_load_js</span><span class="p">()</span><span class="cp">}</span>
  316. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-24"></a><span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  317. <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-25"></a><span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
  318. </pre>
  319. <p>That link which says "Skip to main content" is very important for accessibility, so we will leave it in
  320. place. But below, you can see how it creates the "container" div we see in the Nikola page, and the content is
  321. created by <code class="docutils literal">html_header()</code> which is defined in <code class="docutils literal">base_header.tmpl</code> The actual <code class="docutils literal">nav</code> element is done
  322. by the <code class="docutils literal">html_navigation_links</code> function out of the <code class="docutils literal">NAVIGATION_LINKS</code> and <code class="docutils literal">NAVIGATION_ALT_LINKS</code> options. (Let's put the alt links after regular ones; Bootstrap puts it on the right side, for example.)</p>
  323. <p>So, first, lets change that base template to be more lanyon-like:</p>
  324. <pre class="code html+mako"><a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
  325. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-2"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"base"</span> <span class="na">file=</span><span class="s">"base_helper.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  326. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-3"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"header"</span> <span class="na">file=</span><span class="s">"base_header.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  327. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-4"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"footer"</span> <span class="na">file=</span><span class="s">"base_footer.tmpl"</span> <span class="na">import=</span><span class="s">"*"</span><span class="cp">/&gt;</span>
  328. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-5"></a><span class="cp">${</span><span class="n">set_locale</span><span class="p">(</span><span class="n">lang</span><span class="p">)</span><span class="cp">}</span>
  329. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-6"></a><span class="cp">${</span><span class="n">base</span><span class="o">.</span><span class="n">html_headstart</span><span class="p">()</span><span class="cp">}</span>
  330. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-7"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">&gt;</span>
  331. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-8"></a><span class="cp">### Leave this block alone.</span>
  332. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-9"></a><span class="cp">&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  333. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-10"></a><span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'extra_head'</span><span class="p">]()</span><span class="cp">}</span>
  334. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-11"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  335. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-12"></a><span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  336. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-13"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"#content"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sr-only sr-only-focusable"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">messages</span><span class="p">(</span><span class="s2">"Skip to main content"</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  337. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-14"></a> <span class="c">&lt;!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular</span>
  338. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-15"></a><span class="c"> styles, `#sidebar-checkbox` for behavior. --&gt;</span>
  339. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-16"></a> <span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"checkbox"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span> <span class="na">id</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span><span class="p">&gt;</span>
  340. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-17"></a>
  341. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-18"></a> <span class="c">&lt;!-- Toggleable sidebar --&gt;</span>
  342. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-19"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar"</span> <span class="na">id</span><span class="o">=</span><span class="s">"sidebar"</span><span class="p">&gt;</span>
  343. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-20"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-item"</span><span class="p">&gt;</span>
  344. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-21"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>A reserved <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://getnikola.com"</span> <span class="na">target</span><span class="o">=</span><span class="s">"_blank"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"noopener"</span><span class="p">&gt;</span>Nikola<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> theme that places the utmost gravity on content with a hidden drawer. Made by <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://twitter.com/mdo"</span> <span class="na">target</span><span class="o">=</span><span class="s">"_blank"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"noopener"</span><span class="p">&gt;</span>@mdo<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> for Jekyll,
  345. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-22"></a> ported to Nikola by <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://twitter.com/ralsina"</span> <span class="na">target</span><span class="o">=</span><span class="s">"_blank"</span><span class="p">&gt;</span>@ralsina<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>.<span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  346. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-23"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  347. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-24"></a> <span class="cp">${</span><span class="n">header</span><span class="o">.</span><span class="n">html_navigation_links</span><span class="p">()</span><span class="cp">}</span>
  348. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-25"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  349. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-26"></a>
  350. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-27"></a> <span class="p">&lt;</span><span class="nt">main</span> <span class="na">id</span><span class="o">=</span><span class="s">"content"</span> <span class="na">role</span><span class="o">=</span><span class="s">"main"</span><span class="p">&gt;</span>
  351. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-28"></a> <span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">&gt;&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  352. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-29"></a> <span class="p">&lt;/</span><span class="nt">main</span><span class="p">&gt;</span>
  353. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-30"></a> <span class="cp">${</span><span class="n">footer</span><span class="o">.</span><span class="n">html_footer</span><span class="p">()</span><span class="cp">}</span>
  354. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-31"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
  355. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-32"></a> <span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'body_end'</span><span class="p">]()</span><span class="cp">}</span>
  356. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-33"></a> <span class="cp">${</span><span class="n">base</span><span class="o">.</span><span class="n">late_load_js</span><span class="p">()</span><span class="cp">}</span>
  357. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-34"></a><span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  358. <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-35"></a><span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
  359. </pre>
  360. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-2.png"><img alt="https://getnikola.com/images/lanyon-2.thumbnail.png" src="https://getnikola.com/images/lanyon-2.thumbnail.png"></a>
  361. <figcaption><p>And that’s after I exposed the sidebar by clicking on an invisible widget!</p>
  362. </figcaption></figure><p>One problem, which causes that yellow color in the sidebar is a CSS conflict.
  363. We are loading <code class="docutils literal">rst_base.css</code> which specifies
  364. the background color of <code class="docutils literal">div.sidebar</code> which is more specific than
  365. <code class="docutils literal">lanyon.css</code>, which specifies for <code class="docutils literal">.sidebar</code> alone.</p>
  366. <p>There are many ways to fix this, I chose to change lanyon.css to also use div.sidebar:</p>
  367. <pre class="code css"><a name="rest_code_bad453546fa040adb097fc015dede08a-1"></a><span class="nt">div</span><span class="p">.</span><span class="nc">sidebar</span><span class="o">,</span><span class="p">.</span><span class="nc">sidebar</span> <span class="p">{</span>
  368. <a name="rest_code_bad453546fa040adb097fc015dede08a-2"></a> <span class="k">position</span><span class="p">:</span> <span class="kc">fixed</span><span class="p">;</span>
  369. <a name="rest_code_bad453546fa040adb097fc015dede08a-3"></a> <span class="k">top</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  370. <a name="rest_code_bad453546fa040adb097fc015dede08a-4"></a> <span class="k">bottom</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  371. <a name="rest_code_bad453546fa040adb097fc015dede08a-5"></a> <span class="k">left</span><span class="p">:</span> <span class="mi">-14</span><span class="kt">rem</span><span class="p">;</span>
  372. <a name="rest_code_bad453546fa040adb097fc015dede08a-6"></a> <span class="k">width</span><span class="p">:</span> <span class="mi">14</span><span class="kt">rem</span><span class="p">;</span>
  373. <a name="rest_code_bad453546fa040adb097fc015dede08a-7"></a> <span class="err">[...]</span>
  374. </pre>
  375. <p>This is annoying but it will happen when you just grab CSS from different places. The "Inspect Element"
  376. feature of your web browser is your best friend for these situations.</p>
  377. <p>Another problem is that the contents of the nav element are wrong. They are not bare links. We will fix that in
  378. <code class="docutils literal">base_header.html</code>, like this:</p>
  379. <pre class="code html+mako"><a name="rest_code_608b7cc1e36a477194847e829dea8fc6-1"></a><span class="cp">&lt;%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_navigation_links()"</span><span class="cp">&gt;</span>
  380. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-2"></a> <span class="p">&lt;</span><span class="nt">nav</span> <span class="na">id</span><span class="o">=</span><span class="s">"menu"</span> <span class="na">role</span><span class="o">=</span><span class="s">"navigation"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav"</span><span class="p">&gt;</span>
  381. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-3"></a> <span class="cp">%</span><span class="k">for</span> <span class="n">url</span><span class="p">,</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">navigation_links</span><span class="p">[</span><span class="n">lang</span><span class="p">]:</span>
  382. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-4"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav-item"</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">url</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">text</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  383. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-5"></a> <span class="cp">%</span><span class="k">endfor</span>
  384. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-6"></a> <span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'menu'</span><span class="p">]()</span><span class="cp">}</span>
  385. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-7"></a>
  386. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-8"></a> <span class="cp">%</span><span class="k">for</span> <span class="n">url</span><span class="p">,</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">navigation_alt_links</span><span class="p">[</span><span class="n">lang</span><span class="p">]:</span>
  387. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-9"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav-item"</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">url</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">text</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  388. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-10"></a> <span class="cp">%</span><span class="k">endfor</span>
  389. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-11"></a> <span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'menu_alt'</span><span class="p">]()</span><span class="cp">}</span>
  390. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-12"></a> <span class="p">&lt;/</span><span class="nt">nav</span><span class="p">&gt;</span>
  391. <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-13"></a><span class="cp">&lt;/%</span><span class="nb">def</span><span class="cp">&gt;</span>
  392. </pre>
  393. <p><strong>Note: this means this theme will not support submenus in navigation. If you want that, I’ll happily take a patch.</strong></p>
  394. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-3.png"><img alt="https://getnikola.com/images/lanyon-3.thumbnail.png" src="https://getnikola.com/images/lanyon-3.thumbnail.png"></a>
  395. <figcaption><p>Starting to see a resemblance?</p>
  396. </figcaption></figure><p>Now let’s look at the content. In Lanyon, this is how the "main" content looks:</p>
  397. <pre class="code html"><a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-1"></a><span class="c">&lt;!-- Wrap is the content to shift when toggling the sidebar. We wrap the</span>
  398. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-2"></a><span class="c"> content to avoid any CSS collisions with our real content. --&gt;</span>
  399. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-3"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">&gt;</span>
  400. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-4"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">&gt;</span>
  401. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-5"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">&gt;</span>
  402. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-6"></a> <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">&gt;</span>
  403. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-7"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"/"</span> <span class="na">title</span><span class="o">=</span><span class="s">"Home"</span><span class="p">&gt;</span>Lanyon<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  404. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-8"></a> <span class="p">&lt;</span><span class="nt">small</span><span class="p">&gt;</span>A Jekyll theme<span class="p">&lt;/</span><span class="nt">small</span><span class="p">&gt;</span>
  405. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-9"></a> <span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  406. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-10"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  407. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-11"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  408. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-12"></a>
  409. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-13"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container content"</span><span class="p">&gt;</span>
  410. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-14"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"post"</span><span class="p">&gt;</span>
  411. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-15"></a> <span class="p">&lt;</span><span class="nt">h1</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-title"</span><span class="p">&gt;</span>Introducing Lanyon<span class="p">&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
  412. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-16"></a> <span class="p">&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-date"</span><span class="p">&gt;</span>02 Jan 2014<span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;</span>
  413. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-17"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>Lanyon is an unassuming <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://jekyllrb.com"</span><span class="p">&gt;</span>Jekyll<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> theme [...]
  414. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-18"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  415. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-19"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  416. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-20"></a><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  417. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-21"></a><span class="p">&lt;</span><span class="nt">label</span> <span class="na">for</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-toggle"</span><span class="p">&gt;&lt;/</span><span class="nt">label</span><span class="p">&gt;</span>
  418. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-22"></a><span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  419. <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-23"></a><span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
  420. </pre>
  421. <p>Everything inside the "container content" div is… the content. The rest is a masthead with the site title
  422. and at the bottom a label for the sidebar toggle. Easy to do in <code class="docutils literal">base.tmpl</code>
  423. (only showing the relevant part):</p>
  424. <pre class="code html+mako"><a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-1"></a> <span class="c">&lt;!-- Wrap is the content to shift when toggling the sidebar. We wrap the</span>
  425. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-2"></a><span class="c"> content to avoid any CSS collisions with our real content. --&gt;</span>
  426. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-3"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">&gt;</span>
  427. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-4"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">&gt;</span>
  428. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-5"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">&gt;</span>
  429. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-6"></a> <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">&gt;</span>
  430. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-7"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"/"</span> <span class="na">title</span><span class="o">=</span><span class="s">"Home"</span><span class="p">&gt;</span>Lanyon<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  431. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-8"></a> <span class="p">&lt;</span><span class="nt">small</span><span class="p">&gt;</span>A Jekyll theme<span class="p">&lt;/</span><span class="nt">small</span><span class="p">&gt;</span>
  432. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-9"></a> <span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  433. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-10"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  434. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-11"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  435. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-12"></a>
  436. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-13"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container content"</span> <span class="na">id</span><span class="o">=</span><span class="s">"content"</span><span class="p">&gt;</span>
  437. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-14"></a> <span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">&gt;&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  438. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-15"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  439. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-16"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  440. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-17"></a> <span class="p">&lt;</span><span class="nt">label</span> <span class="na">for</span><span class="o">=</span><span class="s">"sidebar-checkbox"</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-toggle"</span><span class="p">&gt;&lt;/</span><span class="nt">label</span><span class="p">&gt;</span>
  441. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-18"></a> <span class="cp">${</span><span class="n">footer</span><span class="o">.</span><span class="n">html_footer</span><span class="p">()</span><span class="cp">}</span>
  442. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-19"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
  443. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-20"></a> <span class="cp">${</span><span class="n">template_hooks</span><span class="p">[</span><span class="s1">'body_end'</span><span class="p">]()</span><span class="cp">}</span>
  444. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-21"></a> <span class="cp">${</span><span class="n">base</span><span class="o">.</span><span class="n">late_load_js</span><span class="p">()</span><span class="cp">}</span>
  445. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-22"></a><span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  446. <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-23"></a><span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
  447. </pre>
  448. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-4.png"><img alt="https://getnikola.com/images/lanyon-4.thumbnail.png" src="https://getnikola.com/images/lanyon-4.thumbnail.png"></a>
  449. <figcaption><p>Getting there!</p>
  450. </figcaption></figure><p>The sidebar looks bad because of yet more CSS conflicts with <code class="docutils literal">rst_base.css</code>. By
  451. adding some extra styling in <code class="docutils literal">lanyon.css</code>, it will look better.</p>
  452. <pre class="code css"><a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-1"></a><span class="c">/* Style and "hide" the sidebar */</span>
  453. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-2"></a><span class="nt">div</span><span class="p">.</span><span class="nc">sidebar</span><span class="o">,</span> <span class="p">.</span><span class="nc">sidebar</span> <span class="p">{</span>
  454. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-3"></a> <span class="k">position</span><span class="p">:</span> <span class="kc">fixed</span><span class="p">;</span>
  455. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-4"></a> <span class="k">top</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  456. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-5"></a> <span class="k">bottom</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  457. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-6"></a> <span class="k">left</span><span class="p">:</span> <span class="mi">-14</span><span class="kt">rem</span><span class="p">;</span>
  458. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-7"></a> <span class="k">width</span><span class="p">:</span> <span class="mi">14</span><span class="kt">rem</span><span class="p">;</span>
  459. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-8"></a> <span class="k">visibility</span><span class="p">:</span> <span class="kc">hidden</span><span class="p">;</span>
  460. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-9"></a> <span class="k">overflow-y</span><span class="p">:</span> <span class="kc">auto</span><span class="p">;</span>
  461. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-10"></a> <span class="k">padding</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  462. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-11"></a> <span class="k">margin</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  463. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-12"></a> <span class="k">border</span><span class="p">:</span> <span class="kc">none</span><span class="p">;</span>
  464. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-13"></a> <span class="k">font-family</span><span class="p">:</span> <span class="s2">"PT Sans"</span><span class="p">,</span> <span class="n">Helvetica</span><span class="p">,</span> <span class="n">Arial</span><span class="p">,</span> <span class="kc">sans-serif</span><span class="p">;</span>
  465. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-14"></a> <span class="k">font-size</span><span class="p">:</span> <span class="mf">.875</span><span class="kt">rem</span><span class="p">;</span> <span class="c">/* 15px */</span>
  466. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-15"></a> <span class="k">color</span><span class="p">:</span> <span class="nb">rgba</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span><span class="mi">255</span><span class="p">,</span><span class="mi">255</span><span class="p">,</span><span class="mf">.6</span><span class="p">);</span>
  467. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-16"></a> <span class="k">background-color</span><span class="p">:</span> <span class="mh">#202020</span><span class="p">;</span>
  468. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-17"></a> <span class="kp">-webkit-</span><span class="k">transition</span><span class="p">:</span> <span class="kc">all</span> <span class="mf">.3</span><span class="kt">s</span> <span class="kc">ease-in-out</span><span class="p">;</span>
  469. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-18"></a> <span class="k">transition</span><span class="p">:</span> <span class="kc">all</span> <span class="mf">.3</span><span class="kt">s</span> <span class="kc">ease-in-out</span><span class="p">;</span>
  470. <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-19"></a><span class="p">}</span>
  471. </pre>
  472. <p>Also, the accessibility link on top is visible when it should not. That’s
  473. because we removed <code class="docutils literal">theme.css</code> from the base theme, and with it, we lost a
  474. couple of classes. We can add them in <code class="docutils literal">lanyon.css</code>, along with others used by other
  475. pieces of the site:</p>
  476. <pre class="code css"><a name="rest_code_3b340df0699a4d0a9924c68722dd106a-1"></a><span class="p">.</span><span class="nc">sr-only</span> <span class="p">{</span>
  477. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-2"></a> <span class="k">position</span><span class="p">:</span> <span class="kc">absolute</span><span class="p">;</span>
  478. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-3"></a> <span class="k">width</span><span class="p">:</span> <span class="mi">1</span><span class="kt">px</span><span class="p">;</span>
  479. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-4"></a> <span class="k">height</span><span class="p">:</span> <span class="mi">1</span><span class="kt">px</span><span class="p">;</span>
  480. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-5"></a> <span class="k">padding</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  481. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-6"></a> <span class="k">margin</span><span class="p">:</span> <span class="mi">-1</span><span class="kt">px</span><span class="p">;</span>
  482. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-7"></a> <span class="k">overflow</span><span class="p">:</span> <span class="kc">hidden</span><span class="p">;</span>
  483. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-8"></a> <span class="k">clip</span><span class="p">:</span> <span class="nb">rect</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
  484. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-9"></a> <span class="k">border</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  485. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-10"></a><span class="p">}</span>
  486. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-11"></a>
  487. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-12"></a><span class="p">.</span><span class="nc">sr-only-focusable</span><span class="p">:</span><span class="nd">active</span><span class="o">,</span>
  488. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-13"></a><span class="p">.</span><span class="nc">sr-only-focusable</span><span class="p">:</span><span class="nd">focus</span> <span class="p">{</span>
  489. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-14"></a> <span class="k">position</span><span class="p">:</span> <span class="kc">static</span><span class="p">;</span>
  490. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-15"></a> <span class="k">width</span><span class="p">:</span> <span class="kc">auto</span><span class="p">;</span>
  491. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-16"></a> <span class="k">height</span><span class="p">:</span> <span class="kc">auto</span><span class="p">;</span>
  492. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-17"></a> <span class="k">margin</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  493. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-18"></a> <span class="k">overflow</span><span class="p">:</span> <span class="kc">visible</span><span class="p">;</span>
  494. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-19"></a> <span class="k">clip</span><span class="p">:</span> <span class="kc">auto</span><span class="p">;</span>
  495. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-20"></a><span class="p">}</span>
  496. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-21"></a>
  497. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-22"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="p">{</span>
  498. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-23"></a> <span class="k">padding</span><span class="p">:</span> <span class="mi">8</span><span class="kt">px</span> <span class="mi">15</span><span class="kt">px</span><span class="p">;</span>
  499. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-24"></a> <span class="k">margin-bottom</span><span class="p">:</span> <span class="mi">20</span><span class="kt">px</span><span class="p">;</span>
  500. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-25"></a> <span class="k">list-style</span><span class="p">:</span> <span class="kc">none</span><span class="p">;</span>
  501. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-26"></a><span class="p">}</span>
  502. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-27"></a>
  503. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-28"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">&gt;</span> <span class="nt">li</span> <span class="p">{</span>
  504. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-29"></a> <span class="k">display</span><span class="p">:</span> <span class="kc">inline-block</span><span class="p">;</span>
  505. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-30"></a> <span class="k">margin-right</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  506. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-31"></a> <span class="k">margin-left</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  507. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-32"></a><span class="p">}</span>
  508. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-33"></a>
  509. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-34"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">&gt;</span> <span class="nt">li</span><span class="p">:</span><span class="nd">after</span> <span class="p">{</span>
  510. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-35"></a> <span class="k">content</span><span class="p">:</span> <span class="s1">' / '</span><span class="p">;</span>
  511. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-36"></a> <span class="k">color</span><span class="p">:</span> <span class="mh">#888</span><span class="p">;</span>
  512. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-37"></a><span class="p">}</span>
  513. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-38"></a>
  514. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-39"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">&gt;</span> <span class="nt">li</span><span class="p">:</span><span class="nd">last-of-type</span><span class="p">:</span><span class="nd">after</span> <span class="p">{</span>
  515. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-40"></a> <span class="k">content</span><span class="p">:</span> <span class="s1">''</span><span class="p">;</span>
  516. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-41"></a> <span class="k">margin-left</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  517. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-42"></a><span class="p">}</span>
  518. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-43"></a>
  519. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-44"></a><span class="p">.</span><span class="nc">thumbnails</span> <span class="o">&gt;</span> <span class="nt">li</span> <span class="p">{</span>
  520. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-45"></a> <span class="k">display</span><span class="p">:</span> <span class="kc">inline-block</span><span class="p">;</span>
  521. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-46"></a> <span class="k">margin-right</span><span class="p">:</span> <span class="mi">10</span><span class="kt">px</span><span class="p">;</span>
  522. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-47"></a><span class="p">}</span>
  523. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-48"></a>
  524. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-49"></a><span class="p">.</span><span class="nc">thumbnails</span> <span class="o">&gt;</span> <span class="nt">li</span><span class="p">:</span><span class="nd">last-of-type</span> <span class="p">{</span>
  525. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-50"></a> <span class="k">margin-right</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
  526. <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-51"></a><span class="p">}</span>
  527. </pre>
  528. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-5.png"><img alt="https://getnikola.com/images/lanyon-5.thumbnail.png" src="https://getnikola.com/images/lanyon-5.thumbnail.png"></a>
  529. <figcaption><p>Little by little, things look better.</p>
  530. </figcaption></figure><p>One clear problem is that the title "Lanyon · A Jekyll theme" is set in the
  531. theme itself. We don’t do that sort of thing in Nikola, we have settings for
  532. that. So, let’s use them. There is a <code class="docutils literal">html_site_title</code> function in
  533. <code class="docutils literal">base_helper.tmpl</code> which is just the thing. So we change base.tmpl to use it:</p>
  534. <pre class="code html+mako"><a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-1"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">&gt;</span>
  535. <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-2"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">&gt;</span>
  536. <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-3"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">&gt;</span>
  537. <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-4"></a> <span class="cp">${</span><span class="n">header</span><span class="o">.</span><span class="n">html_site_title</span><span class="p">()</span><span class="cp">}</span>
  538. <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-5"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  539. <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-6"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  540. </pre>
  541. <p>That’s a <code class="docutils literal">&lt;h1&gt;</code> instead of a <code class="docutils literal">&lt;h3&gt;</code> like Lanyon does, but hey, it’s the
  542. right thing to do. If you want to go with an <code class="docutils literal">&lt;h3&gt;</code>, just
  543. change <code class="docutils literal">html_site_title</code> itself.</p>
  544. <p>And now we more or less have the correct page layout and styles. Except for a
  545. rather large thing…</p>
  546. </section><section id="typography"><h2>Typography</h2>
  547. <p>You can see in the previous screenshot that text still looks quite different in our port: Serif versus Sans-Serif
  548. content, and the titles have different colors!</p>
  549. <p>Let’s start with the titles. Here’s how they look in Lanyon:</p>
  550. <pre class="code html"><a name="rest_code_e2944f60418c413180b6428673e808af-1"></a><span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">&gt;</span>
  551. <a name="rest_code_e2944f60418c413180b6428673e808af-2"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"/"</span> <span class="na">title</span><span class="o">=</span><span class="s">"Home"</span><span class="p">&gt;</span>Lanyon<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  552. <a name="rest_code_e2944f60418c413180b6428673e808af-3"></a> <span class="p">&lt;</span><span class="nt">small</span><span class="p">&gt;</span>A Jekyll theme<span class="p">&lt;/</span><span class="nt">small</span><span class="p">&gt;</span>
  553. <a name="rest_code_e2944f60418c413180b6428673e808af-4"></a><span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  554. </pre>
  555. <p>Versus our port:</p>
  556. <pre class="code html"><a name="rest_code_0f80e1aa37524d958a0df59a95befa54-1"></a><span class="p">&lt;</span><span class="nt">h1</span> <span class="na">id</span><span class="o">=</span><span class="s">"brand"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"https://example.com/"</span> <span class="na">title</span><span class="o">=</span><span class="s">"My Nikola Site"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"home"</span><span class="p">&gt;</span>
  557. </pre>
  558. <p>So, it looks like we will have to fix <code class="docutils literal">html_site_title</code> after all:</p>
  559. <pre class="code html+mako"><a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-1"></a><span class="cp">&lt;%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_site_title()"</span><span class="cp">&gt;</span>
  560. <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-2"></a> <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">id</span><span class="o">=</span><span class="s">"brand"</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">&gt;</span>
  561. <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-3"></a> <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">_link</span><span class="p">(</span><span class="s2">"root"</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="n">lang</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span> <span class="na">title</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">blog_title</span><span class="cp">}</span><span class="s">"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"home"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">blog_title</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
  562. <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-4"></a> <span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  563. <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-5"></a><span class="cp">&lt;/%</span><span class="nb">def</span><span class="cp">&gt;</span>
  564. </pre>
  565. <p>As for the actual content, that’s not in any of the templates we have seen so far. The page you see is an
  566. "index.tmpl" page, which means it’s a list of blog posts shown one below the
  567. other. Obviously it’s not doing
  568. things in the way the Lanyon CSS expects it to. Here’s the original, which you
  569. can find in Nikola’s source
  570. code:</p>
  571. <pre class="code html+mako"><a name="rest_code_e551bc4dba92475db85b839f6885c89f-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
  572. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-2"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"helper"</span> <span class="na">file=</span><span class="s">"index_helper.tmpl"</span><span class="cp">/&gt;</span>
  573. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-3"></a><span class="cp">&lt;%</span><span class="nb">namespace</span> <span class="na">name=</span><span class="s">"comments"</span> <span class="na">file=</span><span class="s">"comments_helper.tmpl"</span><span class="cp">/&gt;</span>
  574. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-4"></a><span class="cp">&lt;%</span><span class="nb">inherit</span> <span class="na">file=</span><span class="s">"base.tmpl"</span><span class="cp">/&gt;</span>
  575. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-5"></a>
  576. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-6"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">&gt;</span>
  577. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-7"></a> <span class="cp">${</span><span class="n">parent</span><span class="o">.</span><span class="n">extra_head</span><span class="p">()</span><span class="cp">}</span>
  578. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-8"></a> <span class="cp">%</span> <span class="k">if</span> <span class="n">posts</span> <span class="ow">and</span> <span class="p">(</span><span class="n">permalink</span> <span class="o">==</span> <span class="s1">'/'</span> <span class="ow">or</span> <span class="n">permalink</span> <span class="o">==</span> <span class="s1">'/'</span> <span class="o">+</span> <span class="n">index_file</span><span class="p">):</span>
  579. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-9"></a> <span class="p">&lt;</span><span class="nt">link</span> <span class="na">rel</span><span class="o">=</span><span class="s">"prefetch"</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">posts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/html"</span><span class="p">&gt;</span>
  580. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-10"></a> <span class="cp">%</span><span class="k"> endif</span>
  581. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-11"></a><span class="cp">&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  582. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-12"></a>
  583. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-13"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">&gt;</span>
  584. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-14"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content_header"</span><span class="cp">&gt;&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  585. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-15"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"postindex"</span><span class="p">&gt;</span>
  586. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-16"></a><span class="cp">%</span> <span class="k">for</span> <span class="n">post</span> <span class="ow">in</span> <span class="n">posts</span><span class="p">:</span>
  587. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-17"></a> <span class="p">&lt;</span><span class="nt">article</span> <span class="na">class</span><span class="o">=</span><span class="s">"h-entry post-</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'type'</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span>
  588. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-18"></a> <span class="p">&lt;</span><span class="nt">header</span><span class="p">&gt;</span>
  589. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-19"></a> <span class="p">&lt;</span><span class="nt">h1</span> <span class="na">class</span><span class="o">=</span><span class="s">"p-name entry-title"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">class</span><span class="o">=</span><span class="s">"u-url"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">title</span><span class="p">()</span><span class="o">|</span><span class="n">h</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
  590. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-20"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">&gt;</span>
  591. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-21"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline author vcard"</span><span class="p">&gt;&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline-name fn"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">author</span><span class="p">()</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  592. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-22"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"bookmark"</span><span class="p">&gt;&lt;</span><span class="nt">time</span> <span class="na">class</span><span class="o">=</span><span class="s">"published dt-published"</span> <span class="na">datetime</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">title</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">time</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  593. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-23"></a> <span class="cp">%</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'nocomments'</span><span class="p">)</span> <span class="ow">and</span> <span class="n">site_has_comments</span><span class="p">:</span>
  594. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-24"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">comments</span><span class="o">.</span><span class="n">comment_link</span><span class="p">(</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">(),</span> <span class="n">post</span><span class="o">.</span><span class="n">_base_path</span><span class="p">)</span><span class="cp">}</span>
  595. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-25"></a> <span class="cp">%</span><span class="k"> endif</span>
  596. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-26"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  597. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-27"></a> <span class="p">&lt;/</span><span class="nt">header</span><span class="p">&gt;</span>
  598. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-28"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">index_teasers</span><span class="p">:</span>
  599. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-29"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"p-summary entry-summary"</span><span class="p">&gt;</span>
  600. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-30"></a> <span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">teaser_only</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="cp">}</span>
  601. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-31"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  602. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-32"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"e-content entry-content"</span><span class="p">&gt;</span>
  603. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-33"></a> <span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">teaser_only</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="cp">}</span>
  604. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-34"></a> <span class="cp">%</span><span class="k">endif</span>
  605. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-35"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  606. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-36"></a> <span class="p">&lt;/</span><span class="nt">article</span><span class="p">&gt;</span>
  607. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-37"></a><span class="cp">%</span><span class="k"> endfor</span>
  608. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-38"></a><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  609. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-39"></a><span class="cp">${</span><span class="n">helper</span><span class="o">.</span><span class="n">html_pager</span><span class="p">()</span><span class="cp">}</span>
  610. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-40"></a><span class="cp">${</span><span class="n">comments</span><span class="o">.</span><span class="n">comment_link_script</span><span class="p">()</span><span class="cp">}</span>
  611. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-41"></a><span class="cp">${</span><span class="n">helper</span><span class="o">.</span><span class="n">mathjax_script</span><span class="p">(</span><span class="n">posts</span><span class="p">)</span><span class="cp">}</span>
  612. <a name="rest_code_e551bc4dba92475db85b839f6885c89f-42"></a><span class="cp">&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  613. </pre>
  614. <p>And this is how it looks after I played with it for a while, making it generate code that looks closer to
  615. the Lanyon original:</p>
  616. <pre class="code html+mako"><a name="rest_code_fd5122ac420e47ab84bb494729d69912-1"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">&gt;</span>
  617. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-2"></a><span class="cp">&lt;%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content_header"</span><span class="cp">&gt;&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  618. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-3"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"posts"</span><span class="p">&gt;</span>
  619. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-4"></a><span class="cp">%</span> <span class="k">for</span> <span class="n">post</span> <span class="ow">in</span> <span class="n">posts</span><span class="p">:</span>
  620. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-5"></a> <span class="p">&lt;</span><span class="nt">article</span> <span class="na">class</span><span class="o">=</span><span class="s">"post h-entry post-</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'type'</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span>
  621. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-6"></a> <span class="p">&lt;</span><span class="nt">header</span><span class="p">&gt;</span>
  622. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-7"></a> <span class="p">&lt;</span><span class="nt">h1</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-title p-name"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">class</span><span class="o">=</span><span class="s">"u-url"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">title</span><span class="p">()</span><span class="o">|</span><span class="n">h</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">h1</span><span class="p">&gt;</span>
  623. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-8"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">&gt;</span>
  624. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-9"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline author vcard"</span><span class="p">&gt;&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline-name fn"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">author</span><span class="p">()</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  625. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-10"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"bookmark"</span><span class="p">&gt;&lt;</span><span class="nt">time</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-date published dt-published"</span> <span class="na">datetime</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">title</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">time</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  626. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-11"></a> <span class="cp">%</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'nocomments'</span><span class="p">)</span> <span class="ow">and</span> <span class="n">site_has_comments</span><span class="p">:</span>
  627. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-12"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">comments</span><span class="o">.</span><span class="n">comment_link</span><span class="p">(</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">(),</span> <span class="n">post</span><span class="o">.</span><span class="n">_base_path</span><span class="p">)</span><span class="cp">}</span>
  628. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-13"></a> <span class="cp">%</span><span class="k"> endif</span>
  629. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-14"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  630. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-15"></a> <span class="p">&lt;/</span><span class="nt">header</span><span class="p">&gt;</span>
  631. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-16"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">index_teasers</span><span class="p">:</span>
  632. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-17"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"p-summary entry-summary"</span><span class="p">&gt;</span>
  633. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-18"></a> <span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">teaser_only</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="cp">}</span>
  634. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-19"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  635. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-20"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"e-content entry-content"</span><span class="p">&gt;</span>
  636. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-21"></a> <span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="n">teaser_only</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="cp">}</span>
  637. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-22"></a> <span class="cp">%</span><span class="k">endif</span>
  638. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-23"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  639. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-24"></a> <span class="p">&lt;/</span><span class="nt">article</span><span class="p">&gt;</span>
  640. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-25"></a><span class="cp">%</span><span class="k"> endfor</span>
  641. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-26"></a><span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  642. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-27"></a><span class="cp">${</span><span class="n">helper</span><span class="o">.</span><span class="n">html_pager</span><span class="p">()</span><span class="cp">}</span>
  643. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-28"></a><span class="cp">${</span><span class="n">comments</span><span class="o">.</span><span class="n">comment_link_script</span><span class="p">()</span><span class="cp">}</span>
  644. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-29"></a><span class="cp">${</span><span class="n">helper</span><span class="o">.</span><span class="n">mathjax_script</span><span class="p">(</span><span class="n">posts</span><span class="p">)</span><span class="cp">}</span>
  645. <a name="rest_code_fd5122ac420e47ab84bb494729d69912-30"></a><span class="cp">&lt;/%</span><span class="nb">block</span><span class="cp">&gt;</span>
  646. </pre>
  647. <p>With these changes, it looks… similar?</p>
  648. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-6.png"><img alt="https://getnikola.com/images/lanyon-6.thumbnail.png" src="https://getnikola.com/images/lanyon-6.thumbnail.png"></a>
  649. <figcaption><p>It does!</p>
  650. </figcaption></figure><p>Similar changes (basically adding class names to elements) needed to be done in <code class="docutils literal">post_header.tmpl</code>:</p>
  651. <pre class="code html+mako"><a name="rest_code_f471988dc16e43429671b09e47f39316-1"></a><span class="cp">&lt;%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_post_header()"</span><span class="cp">&gt;</span>
  652. <a name="rest_code_f471988dc16e43429671b09e47f39316-2"></a> <span class="p">&lt;</span><span class="nt">header</span><span class="p">&gt;</span>
  653. <a name="rest_code_f471988dc16e43429671b09e47f39316-3"></a> <span class="cp">${</span><span class="n">html_title</span><span class="p">()</span><span class="cp">}</span>
  654. <a name="rest_code_f471988dc16e43429671b09e47f39316-4"></a> <span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">&gt;</span>
  655. <a name="rest_code_f471988dc16e43429671b09e47f39316-5"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline author vcard"</span><span class="p">&gt;&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"byline-name fn"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">author</span><span class="p">()</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  656. <a name="rest_code_f471988dc16e43429671b09e47f39316-6"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">&gt;&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"bookmark"</span><span class="p">&gt;&lt;</span><span class="nt">time</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-date published dt-published"</span> <span class="na">datetime</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span> <span class="na">itemprop</span><span class="o">=</span><span class="s">"datePublished"</span> <span class="na">title</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">formatted_date</span><span class="p">(</span><span class="n">date_format</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">time</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  657. <a name="rest_code_f471988dc16e43429671b09e47f39316-7"></a> <span class="cp">%</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'nocomments'</span><span class="p">)</span> <span class="ow">and</span> <span class="n">site_has_comments</span><span class="p">:</span>
  658. <a name="rest_code_f471988dc16e43429671b09e47f39316-8"></a> <span class="p">&lt;</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">&gt;</span><span class="cp">${</span><span class="n">comments</span><span class="o">.</span><span class="n">comment_link</span><span class="p">(</span><span class="n">post</span><span class="o">.</span><span class="n">permalink</span><span class="p">(),</span> <span class="n">post</span><span class="o">.</span><span class="n">_base_path</span><span class="p">)</span><span class="cp">}</span>
  659. <a name="rest_code_f471988dc16e43429671b09e47f39316-9"></a> <span class="cp">%</span><span class="k"> endif</span>
  660. <a name="rest_code_f471988dc16e43429671b09e47f39316-10"></a> <span class="cp">%</span><span class="k">if</span> <span class="n">post</span><span class="o">.</span><span class="n">description</span><span class="p">():</span>
  661. <a name="rest_code_f471988dc16e43429671b09e47f39316-11"></a> <span class="p">&lt;</span><span class="nt">meta</span> <span class="na">name</span><span class="o">=</span><span class="s">"description"</span> <span class="na">itemprop</span><span class="o">=</span><span class="s">"description"</span> <span class="na">content</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">post</span><span class="o">.</span><span class="n">description</span><span class="p">()</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span>
  662. <a name="rest_code_f471988dc16e43429671b09e47f39316-12"></a> <span class="cp">%</span><span class="k">endif</span>
  663. <a name="rest_code_f471988dc16e43429671b09e47f39316-13"></a> <span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
  664. <a name="rest_code_f471988dc16e43429671b09e47f39316-14"></a> <span class="cp">${</span><span class="n">html_translations</span><span class="p">(</span><span class="n">post</span><span class="p">)</span><span class="cp">}</span>
  665. <a name="rest_code_f471988dc16e43429671b09e47f39316-15"></a> <span class="p">&lt;/</span><span class="nt">header</span><span class="p">&gt;</span>
  666. <a name="rest_code_f471988dc16e43429671b09e47f39316-16"></a><span class="cp">&lt;/%</span><span class="nb">def</span><span class="cp">&gt;</span>
  667. </pre></section><section id="customization"><h2>Customization</h2>
  668. <p>The original Lanyon theme supports some personalization options. It suggests you do them by tweaking the templates, and
  669. you <em>can</em> also do that in the Nikola port. But we prefer to use options for that, so that you can get a later, better
  670. version of the theme and it will still "just work".</p>
  671. <p>Let’s see the color schemes first. They apply easily, just tweak your <code class="docutils literal">body</code> element like this:</p>
  672. <pre class="code html"><a name="rest_code_bbc2c326094f4118b891e33d8631f56c-1"></a><span class="p">&lt;</span><span class="nt">body</span> <span class="na">class</span><span class="o">=</span><span class="s">"theme-base-08"</span><span class="p">&gt;</span>
  673. <a name="rest_code_bbc2c326094f4118b891e33d8631f56c-2"></a>...
  674. <a name="rest_code_bbc2c326094f4118b891e33d8631f56c-3"></a><span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span>
  675. </pre>
  676. <p>We can tweak <code class="docutils literal">base.tmpl</code> to do just that:</p>
  677. <pre class="code html+mako"><a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-1"></a><span class="cp">%</span> <span class="k">if</span> <span class="n">lanyon_subtheme</span><span class="p">:</span>
  678. <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-2"></a><span class="p">&lt;</span><span class="nt">body</span> <span class="na">class</span><span class="o">=</span><span class="s">"</span><span class="cp">${</span><span class="n">lanyon_subtheme</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span>
  679. <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-3"></a><span class="cp">%</span><span class="k">else</span><span class="p">:</span>
  680. <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-4"></a><span class="p">&lt;</span><span class="nt">body</span><span class="p">&gt;</span>
  681. <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-5"></a><span class="cp">%</span><span class="k">endif</span>
  682. </pre>
  683. <p>And then we can put the options in conf.py’s <code class="docutils literal">GLOBAL_CONTEXT</code>:</p>
  684. <pre class="code python"><a name="rest_code_ab8625d895114acc84ba828d69f39931-1"></a><span class="n">GLOBAL_CONTEXT</span> <span class="o">=</span> <span class="p">{</span>
  685. <a name="rest_code_ab8625d895114acc84ba828d69f39931-2"></a> <span class="s2">"lanyon_subtheme"</span><span class="p">:</span> <span class="s2">"theme-base-08"</span>
  686. <a name="rest_code_ab8625d895114acc84ba828d69f39931-3"></a><span class="p">}</span>
  687. </pre>
  688. <figure><a class="reference external image-reference" href="https://getnikola.com/images/lanyon-7.png"><img alt="https://getnikola.com/images/lanyon-7.thumbnail.png" src="https://getnikola.com/images/lanyon-7.thumbnail.png"></a>
  689. <figcaption><p>Look at it, all themed up.</p>
  690. </figcaption></figure><p>Doing the same for layout-reverse, sidebar-overlay and the rest is left as an exercise for the reader.</p>
  691. </section><section id="bundles"><h2>Bundles</h2>
  692. <p>If the <code class="docutils literal">USE_BUNDLES</code> option set to True,
  693. Nikola can put several CSS or JS files together in a larger file, which can
  694. makes site load faster for some deployments. To do this, your theme needs
  695. a <code class="docutils literal">bundles</code> file. The file format is a modified
  696. <a class="reference external" href="https://docs.python.org/3/library/configparser.html">config</a> file with no
  697. defined section; the basic syntax is:</p>
  698. <pre class="literal-block">outputfile1.js=
  699. thing1.js,
  700. thing2.js,
  701. ...
  702. outputfile2.css=
  703. thing1.css,
  704. thing2.css,
  705. ...</pre>
  706. <p>For the Lanyon theme, it should look like this:</p>
  707. <pre class="literal-block">assets/css/all.css=
  708. rst_base.css,
  709. nikola_rst.css,
  710. code.css,
  711. poole.css,
  712. lanyon.css,
  713. custom.css,</pre>
  714. <p><strong>Note:</strong> trailing commas are optional</p>
  715. <p><strong>Note:</strong> Some themes also support the <code class="docutils literal">USE_CDN</code> option meaning that in some cases it will load one bundle with all CSS and in other will load some CSS files
  716. from a CDN and others from a bundle. This is complicated and probably not worth the effort.</p>
  717. </section><section id="the-end"><h2>The End</h2>
  718. <p>And that’s it, that’s a whole theme. Eventually, once people start using it, they will notice small broken details, which will need handling one at a time.</p>
  719. <p>This theme should be available in <a class="reference external" href="https://themes.getnikola.com/v7/lanyon/">https://themes.getnikola.com/v7/lanyon/</a> and you can see it in action at <a class="reference external" href="https://themes.getnikola.com/v7/lanyon/demo/">https://themes.getnikola.com/v7/lanyon/demo/</a> .</p>
  720. <p>What if you want to extend other parts of the theme? Check out the <a class="reference external" href="theming.html">Theming reference</a>. You can also contribute your improvements to the <cite>nikola-themes &lt;https://github.com/getnikola/nikola&gt;</cite> repository on GitHub.</p>
  721. </section>
  722. </div>
  723. </article>
  724. </div>
  725. <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
  726. <div class="sidebar-module sidebar-module-inset">
  727. <h4>About</h4>
  728. <div id="shoutcastdiv">
  729. <script type="text/javascript">
  730. refreshdiv();
  731. </script>
  732. </div>
  733. </div>
  734. <div class="sidebar-module">
  735. <h4>Links</h4>
  736. <ol class="list-unstyled">
  737. <li><a href="http://getbootstrap.com/examples/blog/">Bootstrap Blog Theme</a></li>
  738. <li><a href="https://getnikola.com/">Nikola</a></li>
  739. <li><a href="https://twitter.com/mdo">@mdo</a></li>
  740. <li><a href="https://twitter.com/Kwpolska">@Kwpolska</a></li>
  741. <li><a href="https://twitter.com/GetNikola">@GetNikola</a></li>
  742. </ol>
  743. </div>
  744. </div>
  745. <!--End of body content-->
  746. </div>
  747. </div>
  748. </div>
  749. <footer class="blog-footer" id="footer">
  750. Contents © 2023 <a href="mailto:contact@riff-radio.org">Riff</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
  751. </footer><script src="../assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
  752. moment.locale("en");
  753. fancydates(0, "YYYY-MM-DD HH:mm");
  754. </script><!-- end fancy dates --><script>
  755. baguetteBox.run('div#content', {
  756. ignoreClass: 'islink',
  757. captions: function(element) {
  758. return element.getElementsByTagName('img')[0].alt;
  759. }});
  760. </script><script type="text/javascript" src="../refresh.js"></script>
  761. </body>
  762. </html>