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

theming.html 47KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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>Theming Nikola | 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/theming.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="The Nikola Team">
  12. <meta property="og:site_name" content="Riff">
  13. <meta property="og:title" content="Theming Nikola">
  14. <meta property="og:url" content="http://media.pagelibre.org/riff/site/pages/theming.html">
  15. <meta property="og:description" content="Version:
  16. 8.2.3
  17. Author:
  18. Roberto Alsina &lt;ralsina@netmanagers.com.ar&gt;
  19. Contents
  20. The Structure
  21. Theme meta files
  22. Templates
  23. Built-in templates
  24. Variables available in templates
  25. Customizing themes to user c">
  26. <meta property="og:type" content="article">
  27. <meta property="article:published_time" content="2012-03-13T12:00:00-03:00">
  28. </head>
  29. <body>
  30. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  31. <!-- Menubar -->
  32. <div class="blog-masthead">
  33. <div class="container">
  34. <!-- This keeps the margins nice -->
  35. <nav class="blog-nav" role="navigation"><a href="../index.html" class="blog-nav-item">Accueil</a>
  36. <a href="about.html" class="blog-nav-item">About Riff</a>
  37. <a href="../rss.xml" class="blog-nav-item">RSS feed</a>
  38. </nav>
  39. </div>
  40. <!-- /.container -->
  41. </div>
  42. <!-- End of Menubar -->
  43. <div class="container" id="content" role="main">
  44. <div class="body-content">
  45. <div class="blog-header">
  46. <h1 class="blog-title">
  47. <a href="http://media.pagelibre.org/riff/site/">
  48. <span id="blog-title">Riff</span>
  49. </a>
  50. </h1>
  51. <p class="lead blog-description">Riff la radio rock</p>
  52. </div>
  53. <!--Body content-->
  54. <div class="row">
  55. <div class="col-sm-8 blog-main">
  56. <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">Theming Nikola</a></h2>
  57. </header><div class="e-content entry-content" itemprop="articleBody text">
  58. <dl class="docinfo simple">
  59. <dt class="version">Version<span class="colon">:</span>
  60. </dt>
  61. <dd class="version">8.2.3</dd>
  62. <dt class="author">Author<span class="colon">:</span>
  63. </dt>
  64. <dd class="author"><p>Roberto Alsina &lt;<a class="reference external" href="mailto:ralsina@netmanagers.com.ar">ralsina@netmanagers.com.ar</a>&gt;</p></dd>
  65. </dl>
  66. <nav class="contents alert alert-primary float-md-right" id="contents" role="doc-toc"><p class="topic-title">Contents</p>
  67. <ul class="simple">
  68. <li><p><a class="reference internal" href="theming.html#the-structure" id="toc-entry-1">The Structure</a></p></li>
  69. <li><p><a class="reference internal" href="theming.html#theme-meta-files" id="toc-entry-2">Theme meta files</a></p></li>
  70. <li><p><a class="reference internal" href="theming.html#templates" id="toc-entry-3">Templates</a></p></li>
  71. <li><p><a class="reference internal" href="theming.html#built-in-templates" id="toc-entry-4">Built-in templates</a></p></li>
  72. <li><p><a class="reference internal" href="theming.html#variables-available-in-templates" id="toc-entry-5">Variables available in templates</a></p></li>
  73. <li><p><a class="reference internal" href="theming.html#customizing-themes-to-user-color-preference-colorizing-category-names" id="toc-entry-6">Customizing themes to user color preference, colorizing category names</a></p></li>
  74. <li><p><a class="reference internal" href="theming.html#identifying-and-customizing-different-kinds-of-pages-with-a-shared-template" id="toc-entry-7">Identifying and customizing different kinds of pages with a shared template</a></p></li>
  75. <li><p><a class="reference internal" href="theming.html#messages-and-translations" id="toc-entry-8">Messages and Translations</a></p></li>
  76. <li><p><a class="reference internal" href="theming.html#less-and-sass" id="toc-entry-9">LESS and Sass</a></p></li>
  77. </ul></nav><p class="lead">This document is a reference about themes. If you want a tutorial, please read
  78. <a class="reference external" href="creating-a-theme.html">Creating a Theme</a>. If you’re looking for a ready-made
  79. theme for your site, check out the <a class="reference external" href="https://themes.getnikola.com/">Themes Index</a>.</p>
  80. <section id="the-structure"><h2><a class="toc-backref" href="theming.html#toc-entry-1" role="doc-backlink">The Structure</a></h2>
  81. <p>Themes are located in the <code class="docutils literal">themes</code> folder where Nikola is installed, and in the <code class="docutils literal">themes</code> folder
  82. of your site, one folder per theme. The folder name is the theme name.</p>
  83. <p>A Nikola theme consists of the following folders (they are <em>all</em> optional):</p>
  84. <dl>
  85. <dt>assets</dt>
  86. <dd>
  87. <p>This is where you would put your CSS, JavaScript and image files. It will be copied
  88. into <code class="docutils literal">output/assets</code> when you build the site, and the templates will contain
  89. references to them. The default subdirectories are <code class="docutils literal">css</code>, <code class="docutils literal">js</code>, <code class="docutils literal">xml</code>
  90. and <code class="docutils literal">fonts</code> (Bootstrap).</p>
  91. <p>The included themes use <a class="reference external" href="https://getbootstrap.com/">Bootstrap</a>,
  92. <a class="reference external" href="https://feimosi.github.io/baguetteBox.js/">baguetteBox</a>, <a class="reference external" href="https://flickr.github.io/justified-layout/">Justified Layout by Flickr</a> and <a class="reference external" href="https://moment.github.io/luxon/">Luxon</a>, so they are in assets, along with CSS files for
  93. syntax highlighting, reStructuredText and Jupyter, as well as a minified
  94. copy of jQuery.</p>
  95. <p>If you want to base your theme on other frameworks (or on no framework at all)
  96. just remember to put there everything you need for deployment. (Not all of
  97. the listed assets are used by <code class="docutils literal">base</code>)</p>
  98. </dd>
  99. <dt>templates</dt>
  100. <dd>
  101. <p>This contains the templates used to generate the pages. While Nikola will use a
  102. certain set of template names by default, you can add others for specific parts
  103. of your site.</p>
  104. </dd>
  105. <dt>messages</dt>
  106. <dd>
  107. <p>Nikola tries to be multilingual. This is where you put the strings for your theme
  108. so that it can be translated into other languages.</p>
  109. </dd>
  110. <dt>less, sass</dt>
  111. <dd>
  112. <p>Files to be compiled into CSS using LESS and Sass (both require plugins)</p>
  113. </dd>
  114. </dl>
  115. <p>This mandatory file:</p>
  116. <dl class="simple">
  117. <dt>&lt;theme&gt;.theme</dt>
  118. <dd>
  119. <p>An INI file containing theme meta data. The file format is described in
  120. detail below, in the <a class="reference internal" href="theming.html#theme-meta-files">Theme meta files</a> section.</p>
  121. </dd>
  122. </dl>
  123. <p>And these optional files:</p>
  124. <dl>
  125. <dt>parent, engine</dt>
  126. <dd>
  127. <p>One-line text files that contain the names of parent and engine themes,
  128. respectively. Those are needed for older versions (Nikola v7.8.5 and
  129. older).</p>
  130. </dd>
  131. <dt>bundles</dt>
  132. <dd>
  133. <p>A <a class="reference external" href="https://docs.python.org/3/library/configparser.html">config</a> file
  134. containing a list of files to be turned into bundles. For example:</p>
  135. <pre class="code ini"><a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-1"></a><span class="na">assets/css/all.css</span><span class="o">=</span><span class="s"></span>
  136. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-2"></a><span class="s"> bootstrap.min.css,</span>
  137. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-3"></a><span class="s"> rst_base.css,</span>
  138. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-4"></a><span class="s"> nikola_rst.css,</span>
  139. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-5"></a><span class="s"> code.css,</span>
  140. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-6"></a><span class="s"> baguetteBox.min.css,</span>
  141. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-7"></a><span class="s"> theme.css,</span>
  142. <a name="rest_code_1e62c0f8635c468a9e9e465b2eb0939e-8"></a><span class="s"> custom.css,</span>
  143. </pre>
  144. <p>This creates a file called "assets/css/all.css" in your output that is the
  145. combination of all the other file paths, relative to the output file.
  146. This makes the page much more efficient because it avoids multiple connections to the server,
  147. at the cost of some extra difficult debugging.</p>
  148. <p>Bundling applies to CSS and JS files.</p>
  149. <p>Templates should use either the bundle or the individual files based on the <code class="docutils literal">use_bundles</code>
  150. variable, which in turn is set by the <code class="docutils literal">USE_BUNDLES</code> option.</p>
  151. </dd>
  152. </dl></section><section id="theme-meta-files"><h2><a class="toc-backref" href="theming.html#toc-entry-2" role="doc-backlink">Theme meta files</a></h2>
  153. <p>As of Nikola v7.8.6, Nikola uses meta files for themes. Those are INI files,
  154. with the same name as your theme, and a <code class="docutils literal">.theme</code> extension, eg.
  155. <code class="docutils literal">bootstrap3.theme</code>. Here is an example, from the bootstrap3 theme:</p>
  156. <pre class="code ini"><a name="rest_code_929f518a59e14434bd6c9df89e29e59d-1"></a><span class="k">[Theme]</span>
  157. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-2"></a><span class="na">engine</span> <span class="o">=</span> <span class="s">mako</span>
  158. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-3"></a><span class="na">parent</span> <span class="o">=</span> <span class="s">base</span>
  159. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-4"></a><span class="na">author</span> <span class="o">=</span> <span class="s">The Nikola Contributors</span>
  160. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-5"></a><span class="na">author_url</span> <span class="o">=</span> <span class="s">https://getnikola.com/</span>
  161. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-6"></a><span class="na">based_on</span> <span class="o">=</span> <span class="s">Bootstrap 3 &lt;https://getbootstrap.com/&gt;</span>
  162. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-7"></a><span class="na">license</span> <span class="o">=</span> <span class="s">MIT</span>
  163. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-8"></a><span class="na">tags</span> <span class="o">=</span> <span class="s">bootstrap</span>
  164. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-9"></a>
  165. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-10"></a><span class="k">[Family]</span>
  166. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-11"></a><span class="na">family</span> <span class="o">=</span> <span class="s">bootstrap3</span>
  167. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-12"></a><span class="na">jinja_version</span> <span class="o">=</span> <span class="s">bootstrap3-jinja</span>
  168. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-13"></a><span class="na">variants</span> <span class="o">=</span> <span class="s">bootstrap3-gradients, bootstrap3-gradients-jinja</span>
  169. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-14"></a>
  170. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-15"></a><span class="k">[Nikola]</span>
  171. <a name="rest_code_929f518a59e14434bd6c9df89e29e59d-16"></a><span class="na">bootswatch</span> <span class="o">=</span> <span class="s">True</span>
  172. </pre>
  173. <p>The following keys are currently supported:</p>
  174. <ul>
  175. <li>
  176. <p><code class="docutils literal">Theme</code> — contains information about the theme.</p>
  177. <ul>
  178. <li><p><code class="docutils literal">engine</code> — engine used by the theme. Should be <code class="docutils literal">mako</code> or <code class="docutils literal">jinja</code>.</p></li>
  179. <li>
  180. <p><code class="docutils literal">parent</code> — the parent theme. Any resources missing in this theme, will be
  181. looked up in the parent theme (and then in the grandparent, etc).</p>
  182. <p>The parent is so you don’t have to create a full theme each time: just
  183. create an empty theme, set the parent, and add the bits you want modified.
  184. You <strong>must</strong> define a parent, otherwise many features won’t work due to
  185. missing templates, messages, and assets.</p>
  186. <p>The following settings are recommended:</p>
  187. <ul class="simple">
  188. <li><p>If your theme uses Bootstrap 3, inherit the <code class="docutils literal">bootstrap3</code> theme.</p></li>
  189. <li><p>If your theme uses Jinja as a template engine, inherit <code class="docutils literal"><span class="pre">base-jinja</span></code>
  190. or <code class="docutils literal"><span class="pre">bootstrap3-jinja</span></code></p></li>
  191. <li><p>In any other case, inherit <code class="docutils literal">base</code>.</p></li>
  192. </ul>
  193. </li>
  194. <li><p><code class="docutils literal">author</code>, <code class="docutils literal">author_url</code> — used to identify theme author.</p></li>
  195. <li><p><code class="docutils literal">based_on</code> — optional list of inspirations, frameworks, etc. used in the
  196. theme. Should be comma-separated, the format <code class="docutils literal">Name &lt;URL&gt;</code> is recommended.</p></li>
  197. <li><p><code class="docutils literal">license</code> — theme license. Pick MIT if you have no preference.</p></li>
  198. <li><p><code class="docutils literal">tags</code> — optional list of tags (comma-separated) to describe the theme.</p></li>
  199. </ul>
  200. </li>
  201. <li>
  202. <p><code class="docutils literal">Family</code> — contains information about other related themes. All values
  203. optional. (Do not use unless you have related themes.)</p>
  204. <ul class="simple">
  205. <li><p><code class="docutils literal">family</code> — the name of the main theme in a family, which is also used as
  206. the family name.</p></li>
  207. <li><p><code class="docutils literal">mako_version</code>, <code class="docutils literal">jinja_version</code> — name of the mako/jinja version of the
  208. theme.</p></li>
  209. <li><p><code class="docutils literal">variants</code> — comma-separated list of stylistic variants (other than the
  210. mako/jinja version listed above)</p></li>
  211. </ul>
  212. </li>
  213. <li>
  214. <p><code class="docutils literal">Nikola</code> — Nikola-specific information, currently optional.</p>
  215. <ul class="simple">
  216. <li><p><code class="docutils literal">bootswatch</code> — whether or not theme supports Bootswatch styling (optional,
  217. defaults to False)</p></li>
  218. <li><p><code class="docutils literal">ignored_assets</code> — comma-separated list of assets to ignore (relative to
  219. the <code class="docutils literal">assets/</code> directory, eg. <code class="docutils literal">css/theme.css</code>)</p></li>
  220. </ul>
  221. </li>
  222. </ul></section><section id="templates"><h2><a class="toc-backref" href="theming.html#toc-entry-3" role="doc-backlink">Templates</a></h2>
  223. <p>In templates there is a number of files whose name ends in <code class="docutils literal">.tmpl</code>. Those are the
  224. theme’s page templates. They are done using the <a class="reference external" href="https://www.makotemplates.org">Mako</a>
  225. or <a class="reference external" href="http://jinja.pocoo.org">Jinja2</a> template languages. If you want to do a theme, you
  226. should learn one first. What engine is used by the theme is declared in the <code class="docutils literal">engine</code> file.</p>
  227. <aside class="admonition tip"><p class="admonition-title">Tip</p>
  228. <p>If you are using Mako templates, and want some extra speed when building the site
  229. you can install Beaker and <a class="reference external" href="https://docs.makotemplates.org/en/latest/caching.html">make templates be cached</a></p>
  230. </aside><p>Both template engines have a nifty concept of template inheritance. That means that a
  231. template can inherit from another and only change small bits of the output. For example,
  232. <code class="docutils literal">base.tmpl</code> defines the whole layout for a page but has only a placeholder for content
  233. so <code class="docutils literal">post.tmpl</code> only define the content, and the layout is inherited from <code class="docutils literal">base.tmpl</code>.</p>
  234. <p>Another concept is theme inheritance. You do not need to duplicate all the
  235. default templates in your theme — you can just override the ones you want
  236. changed, and the rest will come from the parent theme. (Every theme needs a
  237. parent.)</p>
  238. <p>Apart from the <a class="reference internal" href="theming.html#built-in-templates">built-in templates</a> listed below, you can add other templates for specific
  239. pages, which the user can then use in his <code class="docutils literal">POSTS</code> or <code class="docutils literal">PAGES</code> option in
  240. <code class="docutils literal">conf.py</code>. Also, you can specify a custom template to be used by a post or
  241. page via the <code class="docutils literal">template</code> metadata, and custom templates can be added in the
  242. <code class="docutils literal">templates/</code> folder of your site.</p>
  243. <p>If you want to modify (override) a built-in template, use <code class="docutils literal">nikola theme <span class="pre">-c</span>
  244. <span class="pre">&lt;name&gt;.tmpl</span></code>. This command will copy the specified template file to the
  245. <code class="docutils literal">templates/</code> directory of your currently used theme.</p>
  246. <p>Keep in mind that your theme is <em>yours</em>, so you can require whatever data you
  247. want (eg. you may depend on specific custom <code class="docutils literal">GLOBAL_CONTEXT</code> variables, or
  248. post meta attributes). You don’t need to keep the same theme structure as the
  249. default themes do (although many of those names are hardcoded). Inheriting from
  250. at least <code class="docutils literal">base</code> (or <code class="docutils literal"><span class="pre">base-jinja</span></code>) is heavily recommended, but not strictly
  251. required (unless you want to share it on the Themes Index).</p>
  252. </section><section id="built-in-templates"><h2><a class="toc-backref" href="theming.html#toc-entry-4" role="doc-backlink">Built-in templates</a></h2>
  253. <p>These are the templates that come with the included themes:</p>
  254. <dl>
  255. <dt><code class="docutils literal">base.tmpl</code></dt>
  256. <dd>
  257. <p>This template defines the basic page layout for the site. It’s mostly plain HTML
  258. but defines a few blocks that can be re-defined by inheriting templates.</p>
  259. <p>It has some separate pieces defined in <code class="docutils literal">base_helper.tmpl</code>,
  260. <code class="docutils literal">base_header.tmpl</code> and <code class="docutils literal">base_footer.tmpl</code> so they can be
  261. easily overridden.</p>
  262. </dd>
  263. <dt><code class="docutils literal">index.tmpl</code></dt>
  264. <dd>
  265. <p>Template used to render the multipost indexes. The posts are in a <code class="docutils literal">posts</code> variable.
  266. Some functionality is in the <code class="docutils literal">index_helper.tmpl</code> helper template.</p>
  267. </dd>
  268. <dt>
  269. <code class="docutils literal">archive_navigation_helper.tmpl</code> (internal)</dt>
  270. <dd>
  271. <p>Code that implements archive navigation (previous/up/next). Included by
  272. archive templates.</p>
  273. </dd>
  274. <dt><code class="docutils literal">archiveindex.tmpl</code></dt>
  275. <dd>
  276. <p>Used to display archives, if <code class="docutils literal">ARCHIVES_ARE_INDEXES</code> is True.
  277. By default, it just inherits <code class="docutils literal">index.tmpl</code>, with added archive navigation
  278. and feeds.</p>
  279. </dd>
  280. <dt><code class="docutils literal">author.tmpl</code></dt>
  281. <dd>
  282. <p>Used to display author pages.</p>
  283. </dd>
  284. <dt><code class="docutils literal">authorindex.tmpl</code></dt>
  285. <dd>
  286. <p>Used to display author indexes, if <code class="docutils literal">AUTHOR_PAGES_ARE_INDEXES</code> is True.
  287. By default, it just inherits <code class="docutils literal">index.tmpl</code>, with added feeds.</p>
  288. </dd>
  289. <dt>
  290. <code class="docutils literal">comments_helper.tmpl</code> (internal)</dt>
  291. <dd>
  292. <p>This template handles comments. You should probably never touch it :-)
  293. It uses a bunch of helper templates, one for each supported comment system
  294. (all of which start with <code class="docutils literal">comments_helper</code>)</p>
  295. </dd>
  296. <dt>
  297. <code class="docutils literal">ui_helper.tmpl</code>, <code class="docutils literal">pagination_helper.tmpl</code>
  298. </dt>
  299. <dd>
  300. <p>These templates help render specific UI items, and can be tweaked as needed.</p>
  301. </dd>
  302. <dt><code class="docutils literal">gallery.tmpl</code></dt>
  303. <dd>
  304. <p>Template used for image galleries. Interesting data includes:</p>
  305. <ul class="simple">
  306. <li><p><code class="docutils literal">post</code>: A post object, containing descriptive <code class="docutils literal">post.text()</code> for the gallery.</p></li>
  307. <li><p><code class="docutils literal">crumbs</code>: A list of <code class="docutils literal">link, crumb</code> to implement breadcrumbs.</p></li>
  308. <li><p><code class="docutils literal">folders</code>: A list of folders to implement hierarchical gallery navigation.</p></li>
  309. <li><p><code class="docutils literal">enable_comments</code>: To enable/disable comments in galleries.</p></li>
  310. <li><p><code class="docutils literal">thumbnail_size</code>: The <code class="docutils literal">THUMBNAIL_SIZE</code> option.</p></li>
  311. <li>
  312. <p><code class="docutils literal">photo_array</code>: a list of dictionaries, each containing:</p>
  313. <ul>
  314. <li><p><code class="docutils literal">url</code>: URL for the full-sized image.</p></li>
  315. <li><p><code class="docutils literal">url_thumb</code>: URL for the thumbnail.</p></li>
  316. <li><p><code class="docutils literal">title</code>: The title of the image.</p></li>
  317. <li><p><code class="docutils literal">size</code>: A dict containing <code class="docutils literal">w</code> and <code class="docutils literal">h</code>, the real size of the thumbnail.</p></li>
  318. </ul>
  319. </li>
  320. <li><p><code class="docutils literal">photo_array_json</code>: a JSON dump of photo_array, used by the
  321. <code class="docutils literal"><span class="pre">justified-layout</span></code> script</p></li>
  322. </ul>
  323. </dd>
  324. <dt><code class="docutils literal">list.tmpl</code></dt>
  325. <dd>
  326. <p>Template used to display generic lists of links, which it gets in <code class="docutils literal">items</code>,
  327. a list of <em>(text, link, count)</em> elements.</p>
  328. </dd>
  329. <dt><code class="docutils literal">list_post.tmpl</code></dt>
  330. <dd>
  331. <p>Template used to display generic lists of posts, which it gets in <code class="docutils literal">posts</code>.</p>
  332. </dd>
  333. <dt><code class="docutils literal">listing.tmpl</code></dt>
  334. <dd>
  335. <p>Used to display code listings.</p>
  336. </dd>
  337. <dt>
  338. <code class="docutils literal">math_helper.tmpl</code> (internal)</dt>
  339. <dd>
  340. <p>Used to add MathJax/KaTeX code to pages.</p>
  341. </dd>
  342. <dt><code class="docutils literal">post.tmpl</code></dt>
  343. <dd>
  344. <p>Template used by default for blog posts, gets the data in a <code class="docutils literal">post</code> object
  345. which is an instance of the Post class. Some functionality is in the
  346. <code class="docutils literal">post_helper.tmpl</code> and <code class="docutils literal">post_header.tmpl</code> templates.</p>
  347. </dd>
  348. <dt><code class="docutils literal">post_list_directive.tmpl</code></dt>
  349. <dd>
  350. <p>Template used by the <code class="docutils literal">post_list</code> reStructuredText directive.</p>
  351. </dd>
  352. <dt><code class="docutils literal">page.tmpl</code></dt>
  353. <dd>
  354. <p>Used for pages that are not part of a blog, usually a cleaner, less
  355. intrusive layout than <code class="docutils literal">post.tmpl</code>, but same parameters.</p>
  356. </dd>
  357. <dt><code class="docutils literal">tag.tmpl</code></dt>
  358. <dd>
  359. <p>Used to show the contents of a single tag or category.</p>
  360. </dd>
  361. <dt><code class="docutils literal">tagindex.tmpl</code></dt>
  362. <dd>
  363. <p>Used to show the contents of a single tag or category, if <code class="docutils literal">TAG_PAGES_ARE_INDEXES</code> is True.
  364. By default, it just inherits <code class="docutils literal">index.tmpl</code>, with added feeds and some
  365. extra features.</p>
  366. </dd>
  367. <dt><code class="docutils literal">tags.tmpl</code></dt>
  368. <dd>
  369. <p>Used to display the list of tags and categories.</p>
  370. </dd>
  371. </dl></section><section id="variables-available-in-templates"><h2><a class="toc-backref" href="theming.html#toc-entry-5" role="doc-backlink">Variables available in templates</a></h2>
  372. <p>The full, complete list of variables available in templates is maintained in a separate
  373. document: <a class="reference external" href="https://getnikola.com/template-variables.html">Template variables</a></p>
  374. </section><section id="customizing-themes-to-user-color-preference-colorizing-category-names"><h2><a class="toc-backref" href="theming.html#toc-entry-6" role="doc-backlink">Customizing themes to user color preference, colorizing category names</a></h2>
  375. <p>The user’s preference for theme color is exposed in templates as
  376. <code class="docutils literal">theme_color</code> set in the <code class="docutils literal">THEME_COLOR</code> option.</p>
  377. <p>This theme color is exposed to the browser in default themes — some browsers
  378. might use this color in the user interface (eg. Chrome on Android in light mode
  379. displays the toolbar in this color).</p>
  380. <p>Nikola also comes with support for auto-generating colors similar to a base
  381. color. This can be used with <code class="docutils literal">theme_color</code> and eg. category names. This
  382. feature is exposed to templates as two functions: <code class="docutils literal">colorize_str(string,
  383. hex_color, presets)</code> and <code class="docutils literal">colorize_str_from_base_color(string, hex_color)</code>.
  384. If you want to display the category name in the color, first define a list of
  385. overrides in your <code class="docutils literal">conf.py</code> file:</p>
  386. <pre class="code python"><a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-1"></a><span class="c1"># end of conf.py</span>
  387. <a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-2"></a><span class="n">GLOBAL_CONTEXT</span> <span class="o">=</span> <span class="p">{</span>
  388. <a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-3"></a> <span class="s2">"category_colors"</span><span class="p">:</span> <span class="p">{</span>
  389. <a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-4"></a> <span class="s2">"Blue"</span><span class="p">:</span> <span class="s2">"#0000FF"</span>
  390. <a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-5"></a> <span class="p">}</span>
  391. <a name="rest_code_e1e6e214a9724e84bd4409ca879f1410-6"></a><span class="p">}</span>
  392. </pre>
  393. <p>With that definition, you can now use <code class="docutils literal">colorize_str</code> in your templates like this:</p>
  394. <pre class="code html+mako"><a name="rest_code_fba7b12c95374a1cbb5c15eb884d099c-1"></a><span class="c">&lt;!-- Mako --&gt;</span>
  395. <a name="rest_code_fba7b12c95374a1cbb5c15eb884d099c-2"></a><span class="p">&lt;</span><span class="nt">span</span> <span class="na">style</span><span class="o">=</span><span class="s">"background-color: </span><span class="cp">${</span><span class="n">colorize_str</span><span class="p">(</span><span class="n">post</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'category'</span><span class="p">),</span> <span class="n">theme_color</span><span class="p">,</span> <span class="n">category_colors</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">meta</span><span class="p">(</span><span class="s1">'category'</span><span class="p">)</span><span class="cp">}</span><span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;</span>
  396. </pre>
  397. <pre class="code html+jinja"><a name="rest_code_61d83b94de6c4f51b3b59b3a4baf9b50-1"></a><span class="c">&lt;!-- Jinja2 --&gt;</span>
  398. <a name="rest_code_61d83b94de6c4f51b3b59b3a4baf9b50-2"></a><span class="p">&lt;</span><span class="nt">span</span> <span class="na">style</span><span class="o">=</span><span class="s">"background-color: </span><span class="cp">{{</span> <span class="nv">colorize_str</span><span class="o">(</span><span class="nv">post.meta</span><span class="o">(</span><span class="s1">'category'</span><span class="o">),</span> <span class="nv">theme_color</span><span class="o">,</span> <span class="nv">category_colors</span><span class="o">)</span> <span class="cp">}}</span><span class="s">"</span><span class="p">&gt;</span><span class="cp">{{</span> <span class="nv">post.meta</span><span class="o">(</span><span class="s1">'category'</span><span class="o">)</span> <span class="cp">}}</span><span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;</span>
  399. </pre>
  400. <p>Note that the category named “Blue” will be displyed in #0000FF due to the
  401. override specified in your config; other categories will have an auto-generated
  402. color visually similar to your theme color.</p>
  403. <p>Hex color values, like that returned by the theme or string colorization can be
  404. altered in the HSL colorspace through the function
  405. <code class="docutils literal">color_hsl_adjust_hex(hex_string, adjust_h, adjust_s, adjust_l)</code>.
  406. Adjustments are given in values between 1.0 and -1.0. For example, the theme
  407. color can be made lighter using this code:</p>
  408. <pre class="code html+mako"><a name="rest_code_09d4261e8af8487ab07c92c3b2b9d794-1"></a><span class="c">&lt;!-- Mako --&gt;</span>
  409. <a name="rest_code_09d4261e8af8487ab07c92c3b2b9d794-2"></a><span class="p">&lt;</span><span class="nt">span</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: </span><span class="cp">${</span><span class="n">color_hsl_adjust_hex</span><span class="p">(</span><span class="n">theme_color</span><span class="p">,</span> <span class="n">adjust_l</span><span class="o">=</span><span class="mf">0.05</span><span class="p">)</span><span class="cp">}</span><span class="s">"</span><span class="p">&gt;</span>
  410. </pre>
  411. <pre class="code html+jinja"><a name="rest_code_11fca1d7d4a942dd8dce2c8624ac1e9c-1"></a><span class="c">&lt;!-- Jinja2 --&gt;</span>
  412. <a name="rest_code_11fca1d7d4a942dd8dce2c8624ac1e9c-2"></a><span class="p">&lt;</span><span class="nt">span</span> <span class="na">style</span><span class="o">=</span><span class="s">"color: </span><span class="cp">{{</span> <span class="nv">color_hsl_adjust_hex</span><span class="o">(</span><span class="nv">theme_color</span><span class="o">,</span> <span class="nv">adjust_l</span><span class="o">=</span><span class="m">0.05</span><span class="o">)</span> <span class="cp">}}</span><span class="s">"</span><span class="p">&gt;</span>
  413. </pre></section><section id="identifying-and-customizing-different-kinds-of-pages-with-a-shared-template"><h2><a class="toc-backref" href="theming.html#toc-entry-7" role="doc-backlink">Identifying and customizing different kinds of pages with a shared template</a></h2>
  414. <p>Nikola provides a <code class="docutils literal">pagekind</code> in each template contexts that can be used to
  415. modify shared templates based on the context it’s being used. For example,
  416. the <code class="docutils literal">base_helper.tmpl</code> is used in all pages, <code class="docutils literal">index.tmpl</code> is used in
  417. many contexts and you may want to add or remove something from only one of
  418. these contexts.</p>
  419. <p>Example of conditionally loading different resources on all index pages
  420. (archives, author pages, and tag pages), and others again to the front page
  421. and in every post pages:</p>
  422. <pre class="code html+mako"><a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-1"></a><span class="c">&lt;!-- Mako --&gt;</span>
  423. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-2"></a><span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  424. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-3"></a> …
  425. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-4"></a> <span class="cp">%</span> <span class="k">if</span> <span class="s1">'index'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  426. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-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/multicolumn.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  427. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-6"></a> <span class="cp">%</span><span class="k"> endif</span>
  428. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-7"></a> <span class="cp">%</span> <span class="k">if</span> <span class="s1">'front_page'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  429. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-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/fancy_homepage.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  430. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-9"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/post_carousel.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  431. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-10"></a> <span class="cp">%</span><span class="k"> endif</span>
  432. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-11"></a> <span class="cp">%</span> <span class="k">if</span> <span class="s1">'post_page'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  433. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-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/article.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  434. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-13"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/comment_system.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  435. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-14"></a> <span class="cp">%</span><span class="k"> endif</span>
  436. <a name="rest_code_8477a412a8d044dfa96ede312ef0d4d8-15"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  437. </pre>
  438. <pre class="code html+jinja"><a name="rest_code_c83f454f264a4909ac8903c54f97d97d-1"></a><span class="c">&lt;!-- Jinja2 --&gt;</span>
  439. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-2"></a><span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span>
  440. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-3"></a> …
  441. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-4"></a> <span class="cp">{%</span> <span class="k">if</span> <span class="s1">'index'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  442. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-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/multicolumn.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  443. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-6"></a> <span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
  444. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-7"></a> <span class="cp">{%</span> <span class="k">if</span> <span class="s1">'front_page'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  445. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-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/fancy_homepage.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  446. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-9"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/post_carousel.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  447. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-10"></a> <span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
  448. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-11"></a> <span class="cp">{%</span> <span class="k">if</span> <span class="s1">'post_page'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  449. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-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/article.css"</span> <span class="na">rel</span><span class="o">=</span><span class="s">"stylesheet"</span><span class="p">&gt;</span>
  450. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-13"></a> <span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">"/assets/js/comment_system.js"</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
  451. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-14"></a> <span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
  452. <a name="rest_code_c83f454f264a4909ac8903c54f97d97d-15"></a><span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span>
  453. </pre>
  454. <p>Promoting visits to the front page when visiting other filtered
  455. <code class="docutils literal">index.tmpl</code> page variants such as author pages and tag pages. This
  456. could have been included in <code class="docutils literal">index.tmpl</code> or maybe in <code class="docutils literal">base.tmpl</code>
  457. depending on what you want to achieve.</p>
  458. <pre class="code html+mako"><a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-1"></a><span class="c">&lt;!-- Mako --&gt;</span>
  459. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-2"></a><span class="cp">%</span> <span class="k">if</span> <span class="s1">'index'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  460. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-3"></a> <span class="cp">%</span> <span class="k">if</span> <span class="s1">'author_page'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  461. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-4"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>These posts were written by <span class="cp">${</span><span class="n">author</span><span class="cp">}</span>. See posts by all
  462. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-5"></a> authors on the <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="p">&gt;</span>front page<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>
  463. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-6"></a> <span class="cp">%</span> <span class="k">elif</span> <span class="s1">'tag_page'</span> <span class="ow">in</span> <span class="n">pagekind</span><span class="p">:</span>
  464. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-7"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>This is a filtered selection of posts tagged “<span class="cp">${</span><span class="n">tag</span><span class="cp">}</span>”, visit
  465. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-8"></a> the <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="p">&gt;</span>front page<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> to see all posts.<span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  466. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-9"></a> <span class="cp">%</span><span class="k"> endif</span>
  467. <a name="rest_code_c1bfafa3138941eab0bf9d2de02c820d-10"></a><span class="cp">%</span><span class="k"> endif</span>
  468. </pre>
  469. <pre class="code html+jinja"><a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-1"></a><span class="c">&lt;!-- Jinja2 --&gt;</span>
  470. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-2"></a><span class="cp">{%</span> <span class="k">if</span> <span class="s1">'index'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  471. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-3"></a> <span class="cp">{%</span> <span class="k">if</span> <span class="s1">'author_page'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  472. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-4"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>These posts were written by <span class="cp">{{</span> <span class="nv">author</span> <span class="cp">}}</span>. See posts by all
  473. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-5"></a> authors on the <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="p">&gt;</span>front page<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>
  474. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-6"></a> <span class="cp">{%</span> <span class="k">elif</span> <span class="s1">'tag_page'</span> <span class="k">in</span> <span class="nv">pagekind</span> <span class="cp">%}</span>
  475. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-7"></a> <span class="p">&lt;</span><span class="nt">p</span><span class="p">&gt;</span>This is a filtered selection of posts tagged “<span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span>”, visit
  476. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-8"></a> the <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="p">&gt;</span>front page<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span> to see all posts.<span class="p">&lt;/</span><span class="nt">p</span><span class="p">&gt;</span>
  477. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-9"></a> <span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
  478. <a name="rest_code_611dcf30e7d4429a95ab119bf2981fdd-10"></a><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
  479. </pre>
  480. <p>List of page kinds provided by default plugins:</p>
  481. <ul class="simple">
  482. <li><p>front_page</p></li>
  483. <li><p>index</p></li>
  484. <li><p>index, archive_page</p></li>
  485. <li><p>index, author_page</p></li>
  486. <li><p>index, main_index</p></li>
  487. <li><p>index, tag_page</p></li>
  488. <li><p>list</p></li>
  489. <li><p>list, archive_page</p></li>
  490. <li><p>list, author_page</p></li>
  491. <li><p>list, tag_page</p></li>
  492. <li><p>list, tags_page</p></li>
  493. <li><p>post_page</p></li>
  494. <li><p>page_page</p></li>
  495. <li><p>story_page</p></li>
  496. <li><p>listing</p></li>
  497. <li><p>generic_page</p></li>
  498. <li><p>gallery_front</p></li>
  499. <li><p>gallery_page</p></li>
  500. </ul></section><section id="messages-and-translations"><h2><a class="toc-backref" href="theming.html#toc-entry-8" role="doc-backlink">Messages and Translations</a></h2>
  501. <p>The included themes are translated into a variety of languages. You can add your own translation
  502. at <a class="reference external" href="https://www.transifex.com/projects/p/nikola/">https://www.transifex.com/projects/p/nikola/</a></p>
  503. <p>If you want to create a theme that has new strings, and you want those strings to be translatable,
  504. then your theme will need a custom <code class="docutils literal">messages</code> folder.</p>
  505. </section><section id="less-and-sass"><h2>
  506. <a class="reference external" href="http://lesscss.org/">LESS</a> and <a class="reference external" href="https://sass-lang.com/">Sass</a>
  507. </h2>
  508. <aside class="admonition note"><p class="admonition-title">Note</p>
  509. <p>The LESS and Sass compilers were moved to the Plugins Index in
  510. Nikola v7.0.0.</p>
  511. </aside><p>If you want to use those CSS extensions, you can — just store your files
  512. in the <code class="docutils literal">less</code> or <code class="docutils literal">sass</code> directory of your theme.</p>
  513. <p>In order to have them work, you need to create a list of <code class="docutils literal">.less</code> or
  514. <code class="docutils literal"><span class="pre">.scss/.sass</span></code> files to compile — the list should be in a file named
  515. <code class="docutils literal">targets</code> in the respective directory (<code class="docutils literal">less</code>/<code class="docutils literal">sass</code>).</p>
  516. <p>The files listed in the <code class="docutils literal">targets</code> file will be passed to the respective
  517. compiler, which you have to install manually (<code class="docutils literal">lessc</code> which comes from
  518. the Node.js package named <code class="docutils literal">less</code> or <code class="docutils literal">sass</code> from a Ruby package aptly
  519. named <code class="docutils literal">sass</code>). Whatever the compiler outputs will be saved as a CSS
  520. file in your rendered site, with the <code class="docutils literal">.css</code> extension.</p>
  521. <aside class="admonition note"><p class="admonition-title">Note</p>
  522. <p>Conflicts may occur if you have two files with the same base name
  523. but a different extension. Pay attention to how you name your files
  524. or your site won’t build! (Nikola will tell you what’s wrong when
  525. this happens)</p>
  526. </aside></section>
  527. </div>
  528. </article>
  529. </div>
  530. <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
  531. <div class="sidebar-module sidebar-module-inset">
  532. <h4>About</h4>
  533. <div id="shoutcastdiv">
  534. <script type="text/javascript">
  535. refreshdiv();
  536. </script>
  537. </div>
  538. </div>
  539. <div class="sidebar-module">
  540. <h4>Links</h4>
  541. <ol class="list-unstyled">
  542. <li><a href="http://getbootstrap.com/examples/blog/">Bootstrap Blog Theme</a></li>
  543. <li><a href="https://getnikola.com/">Nikola</a></li>
  544. <li><a href="https://twitter.com/mdo">@mdo</a></li>
  545. <li><a href="https://twitter.com/Kwpolska">@Kwpolska</a></li>
  546. <li><a href="https://twitter.com/GetNikola">@GetNikola</a></li>
  547. </ol>
  548. </div>
  549. </div>
  550. <!--End of body content-->
  551. </div>
  552. </div>
  553. </div>
  554. <footer class="blog-footer" id="footer">
  555. Contents © 2023 <a href="mailto:contact@riff-radio.org">Riff</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
  556. </footer><script src="../assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
  557. moment.locale("en");
  558. fancydates(0, "YYYY-MM-DD HH:mm");
  559. </script><!-- end fancy dates --><script>
  560. baguetteBox.run('div#content', {
  561. ignoreClass: 'islink',
  562. captions: function(element) {
  563. return element.getElementsByTagName('img')[0].alt;
  564. }});
  565. </script><script type="text/javascript" src="../refresh.js"></script>
  566. </body>
  567. </html>