123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Creating a Theme | Riff</title>
- <link href="../assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
- <link rel="alternate" type="application/rss+xml" title="RSS" href="../rss.xml">
- <link rel="canonical" href="http://media.pagelibre.org/riff/site/pages/creating-a-theme.html">
- <link rel="icon" href="../favicon.ico" sizes="16x16">
- <!--[if lt IE 9]><script src="../assets/js/html5.js"></script><![endif]--><meta name="author" content="Riff">
- <meta property="og:site_name" content="Riff">
- <meta property="og:title" content="Creating a Theme">
- <meta property="og:url" content="http://media.pagelibre.org/riff/site/pages/creating-a-theme.html">
- <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,
- I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.
- This docum">
- <meta property="og:type" content="article">
- <meta property="article:published_time" content="2015-05-28T18:46:48Z">
- </head>
- <body>
- <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
-
- <!-- Menubar -->
-
- <div class="blog-masthead">
- <div class="container">
- <!-- This keeps the margins nice -->
- <nav class="blog-nav" role="navigation"><a href="../index.html" class="blog-nav-item">Accueil</a>
- <a href="about.html" class="blog-nav-item">About Riff</a>
- <a href="../rss.xml" class="blog-nav-item">RSS feed</a>
-
-
-
-
-
-
-
- </nav>
- </div>
- <!-- /.container -->
- </div>
- <!-- End of Menubar -->
-
- <div class="container" id="content" role="main">
- <div class="body-content">
- <div class="blog-header">
- <h1 class="blog-title">
- <a href="http://media.pagelibre.org/riff/site/">
-
- <span id="blog-title">Riff</span>
- </a>
- </h1>
- <p class="lead blog-description">Riff la radio rock</p>
-
- </div>
- <!--Body content-->
- <div class="row">
- <div class="col-sm-8 blog-main">
-
- <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>
-
-
-
- </header><div class="e-content entry-content" itemprop="articleBody text">
- <p>Nikola is a static site and blog generator. So is Jekyll. While I like what we have done with Nikola,
- I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.</p>
- <p>This document is an attempt at making it easier for 3rd parties (that means <em>you</em> people! ;-) to
- create themes. Since I <strong>suck</strong> at designing websites, I asked for opinions on themes to port,
- and got some feedback. Since this is <strong>Not So Hard™</strong>, I will try to make time to port a few
- and see what happens.</p>
- <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>
- <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>
- and released under a MIT license, which is liberal enough.</p>
- <p>So, let’s get started.</p>
- <section id="checking-it-out"><h2>Checking It Out</h2>
- <p>The first step in porting a theme is making the original theme work. Lanyon is awesome in that its
- <a class="reference external" href="https://github.com/poole/lanyon">GitHub project</a> is a full site!</p>
- <p>So:</p>
- <pre class="literal-block"># Get jekyll
- sudo apt-get install jekyll
-
- # Get Lanyon
- git clone git@github.com:poole/lanyon.git
-
- # Build it
- cd lanyon && jekyll build
-
- # Look at it
- jekyll serve & google-chrome http://localhost:4000</pre>
- <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>
- <p>Some things jump to my mind:</p>
- <ol class="arabic simple">
- <li><p>This is one fine looking theme</p></li>
- <li><p>Very clear and readable</p></li>
- <li><p>Nice hidden navigation-thingy</p></li>
- </ol>
- <p>Also, from looking at <a class="reference external" href="https://github.com/poole/lanyon/blob/master/README.md">the project’s README</a>
- it supports some nice configuration options:</p>
- <ol class="arabic simple">
- <li><p>Color schemes</p></li>
- <li><p>Reverse layout</p></li>
- <li><p>Sidebar overlay instead of push</p></li>
- <li><p>Open the sidebar by default, or on a per-page basis by using its metadata</p></li>
- </ol>
- <p>Let’s try to make all those nice things survive the porting.</p>
- </section><section id="starting-from-somewhere"><h2>Starting From Somewhere</h2>
- <p>Nikola has a nice, clean, base theme from which you can start when writing your own theme.
- Why start from that instead of from a clean slate? Because theme inheritance is going to save you a ton of work,
- that’s why. If you start from scratch you won’t be able to build <strong>anything</strong> until you have a bunch of
- templates written. Starting from base, you just need to hack on the things you <strong>need</strong> to change.</p>
- <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>
- <pre class="literal-block">$ nikola init --demo lanyon-port
- Creating Nikola Site
- ====================
-
- This is Nikola v7.8.0. We will now ask you a few easy questions about your new site.
- If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.
- --- Questions about the site ---
- Site title [My Nikola Site]:
- Site author [Nikola Tesla]:
- Site author's e-mail [n.tesla@example.com]:
- Site description [This is a demo site for Nikola.]:
- Site URL [https://example.com/]:
- --- Questions about languages and locales ---
- We will now ask you to provide the list of languages you want to use.
- Please list all the desired languages, comma-separated, using ISO 639-1 codes. The first language will be used as the default.
- Type '?' (a question mark, sans quotes) to list available languages.
- Language(s) to use [en]:
-
- Please choose the correct time zone for your blog. Nikola uses the tz database.
- You can find your time zone here:
- https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
-
- Time zone [UTC]:
- Current time in UTC: 16:02:07
- Use this time zone? [Y/n]
- --- Questions about comments ---
- 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.
- Comment system:
-
- That's it, Nikola is now configured. Make sure to edit conf.py to your liking.
- If you are looking for themes and addons, check out https://themes.getnikola.com/ and https://plugins.getnikola.com/.
- Have fun!
- [2015-05-28T16:02:08Z] INFO: init: A new site with example data has been created at lanyon-port.
- [2015-05-28T16:02:08Z] INFO: init: See README.txt in that folder for more information.</pre>
- <p>Then, we create an empty theme inheriting from base. This theme will use Mako templates. If you prefer Jinja2,
- 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>
- <pre class="literal-block">$ cd lanyon-port/
- $ nikola theme -n lanyon --parent base --engine mako</pre>
- <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).
- 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>
- <p>You can now build that site using <code class="docutils literal">nikola build</code> and it will look like this:</p>
- <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>
- <figcaption><p>This is just the base theme.</p>
- </figcaption></figure></section><section id="basic-css"><h2>Basic CSS</h2>
- <p>The next step is to know exactly how Lanyon’s pages work. To do this, we read its HTML.
- First let’s look at the head element:</p>
- <pre class="code html"><a name="rest_code_aaccd00a36264f57b74893d4eb903571-1"></a><span class="cp"><!DOCTYPE html></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-2"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-3"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-4"></a><span class="p"><</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-5"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-6"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-7"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-8"></a><span class="c"><!-- Enable responsiveness on mobile devices--></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-9"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-10"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-11"></a><span class="p"><</span><span class="nt">title</span><span class="p">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-12"></a> Lanyon <span class="ni">&middot;</span> A Jekyll theme
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-13"></a><span class="p"></</span><span class="nt">title</span><span class="p">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-14"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-15"></a><span class="c"><!-- CSS --></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-16"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-17"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-18"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-19"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-20"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-21"></a><span class="c"><!-- Icons --></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-22"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-23"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-24"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-25"></a><span class="c"><!-- RSS --></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-26"></a><span class="p"><</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">></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-27"></a>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-28"></a><span class="c"><!-- Google Analytics --></span>
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-29"></a>[...]
- <a name="rest_code_aaccd00a36264f57b74893d4eb903571-30"></a><span class="p"></</span><span class="nt">head</span><span class="p">></span>
- </pre>
- <p>The interesting part there is that it loads a few CSS files. If you check the source of your Nikola site, you will
- see something fairly similar:</p>
- <pre class="code html"><a name="rest_code_990036230fdd4f33818ff702e2f5ec35-1"></a><span class="cp"><!DOCTYPE html></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-2"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-3"></a><span class="p"><</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-4"></a><span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-5"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-6"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-7"></a><span class="p"><</span><span class="nt">title</span><span class="p">></span>My Nikola Site | My Nikola Site<span class="p"></</span><span class="nt">title</span><span class="p">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-8"></a>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-9"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-10"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-11"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-12"></a>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-13"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-14"></a><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-15"></a><span class="c"><!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]--></span><span class="p"><</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">></span>
- <a name="rest_code_990036230fdd4f33818ff702e2f5ec35-16"></a><span class="p"></</span><span class="nt">head</span><span class="p">></span>
- </pre>
- <p>Luckily, since this is all under a very liberal license, we can just copy these CSS files into
- Nikola, adapting the paths a little so that they follow our conventions:</p>
- <pre class="literal-block">$ mkdir -p themes/lanyon/assets/css
- $ cp ../lanyon/public/css/poole.css themes/lanyon/assets/css/
- $ cp ../lanyon/public/css/lanyon.css themes/lanyon/assets/css/</pre>
- <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
- in a particular way, using a setting called <code class="docutils literal">CODE_COLOR_SCHEME</code> where you can configure
- what color scheme the syntax highlighter uses. You can use your own <code class="docutils literal">assets/css/code.css</code> if you
- don’t like the provided ones.</p>
- <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.
- We will also add themes for Jupyter (<code class="docutils literal">assets/css/ipython.min.css</code>
- and <code class="docutils literal">assets/css/nikola_ipython.css</code>) into the template; note that they are
- activated only if you configured your <code class="docutils literal">POSTS</code>/<code class="docutils literal">PAGES</code> with ipynb support.
- There’s also <code class="docutils literal">assets/css/nikola_rst.css</code>, which adds Bootstrap 3-style reST notes etc.</p>
- <p>But how do I tell <strong>our</strong> lanyon theme to use those CSS files instead of whatever it’s using now?
- By giving our theme its own base_helper.tmpl.</p>
- <p>That file is a <strong>template</strong> used to generate parts of the pages. It’s large and
- complicated but we don’t need to change a lot of it. First, make a copy in your
- theme (note this command requires setting your <code class="docutils literal">THEME</code> in <code class="docutils literal">conf.py</code> to
- <code class="docutils literal">lanyon</code>):</p>
- <pre class="literal-block">$ nikola theme -c base_helper.tmpl</pre>
- <p>The part we want to change is this:</p>
- <pre class="code html+mako"><a name="rest_code_adacc386e77a4a0ca76f3f5965909385-1"></a><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_stylesheets()"</span><span class="cp">></span>
- <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>
- <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>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-4"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-5"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-6"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-7"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-8"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-9"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-10"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-11"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-12"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-14"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-15"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-16"></a> <span class="cp">%</span><span class="k">endif</span>
- <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>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-18"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-19"></a> <span class="p"><</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">></span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-20"></a> <span class="cp">%</span><span class="k"> endif</span>
- <a name="rest_code_adacc386e77a4a0ca76f3f5965909385-21"></a><span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
- </pre>
- <p>And we will change it so it uses the lanyon styles instead of theme.css (again, ignore the bundles for now!):</p>
- <pre class="code html+mako"><a name="rest_code_481d3ff311a64503aa44d20cc132c419-1"></a><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_stylesheets()"</span><span class="cp">></span>
- <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>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-3"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-4"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-5"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-6"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-7"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-8"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-9"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-11"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-12"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-13"></a> <span class="cp">%</span><span class="k">endif</span>
- <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>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-15"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-16"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-17"></a> <span class="cp">%</span><span class="k"> endif</span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-18"></a> <span class="p"><</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">></span>
- <a name="rest_code_481d3ff311a64503aa44d20cc132c419-19"></a><span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
- </pre>
- <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>
- <figcaption><p>You may say this looks like crap. Don’t worry, we are just starting :-)</p>
- </figcaption></figure></section><section id="page-layout"><h2>Page Layout</h2>
- <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>
- <p>Lanyon’s content is split in two parts: a sidebar and the rest. The sidebar looks like this (shortened for comprehension):</p>
- <pre class="code html"><a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-1"></a><span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-2"></a><span class="c"><!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular</span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-3"></a><span class="c"> styles, `#sidebar-checkbox` for behavior. --></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-4"></a><span class="p"><</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">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-5"></a>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-6"></a><span class="c"><!-- Toggleable sidebar --></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-7"></a><span class="p"><</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">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-8"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-item"</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-9"></a> <span class="p"><</span><span class="nt">p</span><span class="p">></span>A reserved <span class="p"><</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">></span>Jekyll<span class="p"></</span><span class="nt">a</span><span class="p">></span> theme that places the utmost gravity on content with a hidden drawer. Made by <span class="p"><</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">></span>@mdo<span class="p"></</span><span class="nt">a</span><span class="p">></span>.<span class="p"></</span><span class="nt">p</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-10"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-11"></a>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-12"></a> <span class="p"><</span><span class="nt">nav</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-nav"</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-13"></a> <span class="p"><</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">></span>Home<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-14"></a> <span class="p"><</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">></span>About<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-15"></a> [...]
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-16"></a> <span class="p"></</span><span class="nt">nav</span><span class="p">></span>
- <a name="rest_code_cf308091aa514e15b5a33ebf5a9e58dd-17"></a><span class="p"></</span><span class="nt">div</span><span class="p">></span>
- </pre>
- <p>So, a plain body, with an input element that controls the sidebar, a div which is the sidebar itself.
- Inside that, div.sidebar-item for items, and a nav with "navigational links". This is followed by the "masthead" and
- the content itself, which we will look at in a bit.</p>
- <p>If we look for the equivalent code in Nikola’s side, we see this:</p>
- <pre class="code html"><a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-1"></a><span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-2"></a><span class="p"><</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">></span>Skip to main content<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-3"></a><span class="p"><</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"container"</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-4"></a><span class="p"><</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">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-5"></a><span class="p"><</span><span class="nt">h1</span> <span class="na">id</span><span class="o">=</span><span class="s">"brand"</span><span class="p">><</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">></span> <span class="p"><</span><span class="nt">span</span> <span class="na">id</span><span class="o">=</span><span class="s">"blog-title"</span><span class="p">></span>My Nikola Site<span class="p"></</span><span class="nt">span</span><span class="p">></span> <span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">h1</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-6"></a><span class="p"><</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">><</span><span class="nt">ul</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-7"></a><span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"../archive.html"</span><span class="p">></span>Archive<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-8"></a> <span class="p"><</span><span class="nt">li</span><span class="p">><</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">></span>Tags<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
- <a name="rest_code_557cdd996ffb47e78ccbe28c4f35baa5-9"></a> <span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"../rss.xml"</span><span class="p">></span>RSS feed<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">li</span><span class="p">></span>
- </pre>
- <p>So Nikola has the "masthead" above the nav element, and uses list elements in nav instead of bare links.
- Not all that different is it?</p>
- <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>
- <p>Let’s look at <code class="docutils literal">base.tmpl</code> first. It’s short and nice, it looks like a webpage without
- all the interesting stuff:</p>
- <pre class="code html+mako"><a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-2"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-3"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-4"></a><span class="cp"><%</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">/></span>
- <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>
- <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>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-7"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-8"></a><span class="cp">### Leave this block alone.</span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-9"></a><span class="cp"></%</span><span class="nb">block</span><span class="cp">></span>
- <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>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-11"></a><span class="p"></</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-12"></a><span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-13"></a><span class="p"><</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">></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"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-14"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"container"</span><span class="p">></span>
- <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>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-16"></a> <span class="p"><</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">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-17"></a> <span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-18"></a> <span class="p"></</span><span class="nt">main</span><span class="p">></span>
- <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>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-20"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-21"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
- <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>
- <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>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-24"></a><span class="p"></</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_4dee5332d49f482b8cb7522fb5db9060-25"></a><span class="p"></</span><span class="nt">html</span><span class="p">></span>
- </pre>
- <p>That link which says "Skip to main content" is very important for accessibility, so we will leave it in
- place. But below, you can see how it creates the "container" div we see in the Nikola page, and the content is
- 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
- 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>
- <p>So, first, lets change that base template to be more lanyon-like:</p>
- <pre class="code html+mako"><a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-2"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-3"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-4"></a><span class="cp"><%</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">/></span>
- <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>
- <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>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-7"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-8"></a><span class="cp">### Leave this block alone.</span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-9"></a><span class="cp"></%</span><span class="nb">block</span><span class="cp">></span>
- <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>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-11"></a><span class="p"></</span><span class="nt">head</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-12"></a><span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-13"></a> <span class="p"><</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">></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"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-14"></a> <span class="c"><!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular</span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-15"></a><span class="c"> styles, `#sidebar-checkbox` for behavior. --></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-16"></a> <span class="p"><</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">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-17"></a>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-18"></a> <span class="c"><!-- Toggleable sidebar --></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-19"></a> <span class="p"><</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">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-20"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"sidebar-item"</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-21"></a> <span class="p"><</span><span class="nt">p</span><span class="p">></span>A reserved <span class="p"><</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">></span>Nikola<span class="p"></</span><span class="nt">a</span><span class="p">></span> theme that places the utmost gravity on content with a hidden drawer. Made by <span class="p"><</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">></span>@mdo<span class="p"></</span><span class="nt">a</span><span class="p">></span> for Jekyll,
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-22"></a> ported to Nikola by <span class="p"><</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">></span>@ralsina<span class="p"></</span><span class="nt">a</span><span class="p">></span>.<span class="p"></</span><span class="nt">p</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-23"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <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>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-25"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-26"></a>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-27"></a> <span class="p"><</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">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-28"></a> <span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-29"></a> <span class="p"></</span><span class="nt">main</span><span class="p">></span>
- <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>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-31"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
- <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>
- <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>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-34"></a><span class="p"></</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_fc89fb81b5d44b0fb54d746832f1e6d2-35"></a><span class="p"></</span><span class="nt">html</span><span class="p">></span>
- </pre>
- <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>
- <figcaption><p>And that’s after I exposed the sidebar by clicking on an invisible widget!</p>
- </figcaption></figure><p>One problem, which causes that yellow color in the sidebar is a CSS conflict.
- We are loading <code class="docutils literal">rst_base.css</code> which specifies
- the background color of <code class="docutils literal">div.sidebar</code> which is more specific than
- <code class="docutils literal">lanyon.css</code>, which specifies for <code class="docutils literal">.sidebar</code> alone.</p>
- <p>There are many ways to fix this, I chose to change lanyon.css to also use div.sidebar:</p>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_bad453546fa040adb097fc015dede08a-7"></a> <span class="err">[...]</span>
- </pre>
- <p>This is annoying but it will happen when you just grab CSS from different places. The "Inspect Element"
- feature of your web browser is your best friend for these situations.</p>
- <p>Another problem is that the contents of the nav element are wrong. They are not bare links. We will fix that in
- <code class="docutils literal">base_header.html</code>, like this:</p>
- <pre class="code html+mako"><a name="rest_code_608b7cc1e36a477194847e829dea8fc6-1"></a><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_navigation_links()"</span><span class="cp">></span>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-2"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-4"></a> <span class="p"><</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">></span><span class="cp">${</span><span class="n">text</span><span class="cp">}</span><span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-5"></a> <span class="cp">%</span><span class="k">endfor</span>
- <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>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-7"></a>
- <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>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-9"></a> <span class="p"><</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">></span><span class="cp">${</span><span class="n">text</span><span class="cp">}</span><span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-10"></a> <span class="cp">%</span><span class="k">endfor</span>
- <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>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-12"></a> <span class="p"></</span><span class="nt">nav</span><span class="p">></span>
- <a name="rest_code_608b7cc1e36a477194847e829dea8fc6-13"></a><span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
- </pre>
- <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>
- <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>
- <figcaption><p>Starting to see a resemblance?</p>
- </figcaption></figure><p>Now let’s look at the content. In Lanyon, this is how the "main" content looks:</p>
- <pre class="code html"><a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-1"></a><span class="c"><!-- Wrap is the content to shift when toggling the sidebar. We wrap the</span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-2"></a><span class="c"> content to avoid any CSS collisions with our real content. --></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-3"></a><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-4"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-5"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-6"></a> <span class="p"><</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-7"></a> <span class="p"><</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">></span>Lanyon<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-8"></a> <span class="p"><</span><span class="nt">small</span><span class="p">></span>A Jekyll theme<span class="p"></</span><span class="nt">small</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-9"></a> <span class="p"></</span><span class="nt">h3</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-10"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-11"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-12"></a>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-13"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container content"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-14"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"post"</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-15"></a> <span class="p"><</span><span class="nt">h1</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-title"</span><span class="p">></span>Introducing Lanyon<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-16"></a> <span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"post-date"</span><span class="p">></span>02 Jan 2014<span class="p"></</span><span class="nt">span</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-17"></a> <span class="p"><</span><span class="nt">p</span><span class="p">></span>Lanyon is an unassuming <span class="p"><</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">></span>Jekyll<span class="p"></</span><span class="nt">a</span><span class="p">></span> theme [...]
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-18"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-19"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-20"></a><span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-21"></a><span class="p"><</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">></</span><span class="nt">label</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-22"></a><span class="p"></</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_965ba81d3aa44aa991feb7dec4b71fe0-23"></a><span class="p"></</span><span class="nt">html</span><span class="p">></span>
- </pre>
- <p>Everything inside the "container content" div is… the content. The rest is a masthead with the site title
- and at the bottom a label for the sidebar toggle. Easy to do in <code class="docutils literal">base.tmpl</code>
- (only showing the relevant part):</p>
- <pre class="code html+mako"><a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-1"></a> <span class="c"><!-- Wrap is the content to shift when toggling the sidebar. We wrap the</span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-2"></a><span class="c"> content to avoid any CSS collisions with our real content. --></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-3"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-4"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-5"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-6"></a> <span class="p"><</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-7"></a> <span class="p"><</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">></span>Lanyon<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-8"></a> <span class="p"><</span><span class="nt">small</span><span class="p">></span>A Jekyll theme<span class="p"></</span><span class="nt">small</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-9"></a> <span class="p"></</span><span class="nt">h3</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-10"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-11"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-12"></a>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-13"></a> <span class="p"><</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">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-14"></a> <span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-15"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-16"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-17"></a> <span class="p"><</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">></</span><span class="nt">label</span><span class="p">></span>
- <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>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-19"></a> <span class="cp">${</span><span class="n">body_end</span><span class="cp">}</span>
- <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>
- <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>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-22"></a><span class="p"></</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_48adeb55557c44a28e38822f50eb3ac6-23"></a><span class="p"></</span><span class="nt">html</span><span class="p">></span>
- </pre>
- <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>
- <figcaption><p>Getting there!</p>
- </figcaption></figure><p>The sidebar looks bad because of yet more CSS conflicts with <code class="docutils literal">rst_base.css</code>. By
- adding some extra styling in <code class="docutils literal">lanyon.css</code>, it will look better.</p>
- <pre class="code css"><a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-1"></a><span class="c">/* Style and "hide" the sidebar */</span>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_7cfd88bc25024630b0a2eab6659f2a9f-19"></a><span class="p">}</span>
- </pre>
- <p>Also, the accessibility link on top is visible when it should not. That’s
- because we removed <code class="docutils literal">theme.css</code> from the base theme, and with it, we lost a
- couple of classes. We can add them in <code class="docutils literal">lanyon.css</code>, along with others used by other
- pieces of the site:</p>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-10"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-11"></a>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-20"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-21"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-22"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="p">{</span>
- <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>
- <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>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-26"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-27"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-28"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">></span> <span class="nt">li</span> <span class="p">{</span>
- <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>
- <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>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-32"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-33"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-34"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">></span> <span class="nt">li</span><span class="p">:</span><span class="nd">after</span> <span class="p">{</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-35"></a> <span class="k">content</span><span class="p">:</span> <span class="s1">' / '</span><span class="p">;</span>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-37"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-38"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-39"></a><span class="p">.</span><span class="nc">breadcrumb</span> <span class="o">></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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-40"></a> <span class="k">content</span><span class="p">:</span> <span class="s1">''</span><span class="p">;</span>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-42"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-43"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-44"></a><span class="p">.</span><span class="nc">thumbnails</span> <span class="o">></span> <span class="nt">li</span> <span class="p">{</span>
- <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>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-47"></a><span class="p">}</span>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-48"></a>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-49"></a><span class="p">.</span><span class="nc">thumbnails</span> <span class="o">></span> <span class="nt">li</span><span class="p">:</span><span class="nd">last-of-type</span> <span class="p">{</span>
- <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>
- <a name="rest_code_3b340df0699a4d0a9924c68722dd106a-51"></a><span class="p">}</span>
- </pre>
- <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>
- <figcaption><p>Little by little, things look better.</p>
- </figcaption></figure><p>One clear problem is that the title "Lanyon · A Jekyll theme" is set in the
- theme itself. We don’t do that sort of thing in Nikola, we have settings for
- that. So, let’s use them. There is a <code class="docutils literal">html_site_title</code> function in
- <code class="docutils literal">base_helper.tmpl</code> which is just the thing. So we change base.tmpl to use it:</p>
- <pre class="code html+mako"><a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-1"></a><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"wrap"</span><span class="p">></span>
- <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-2"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead"</span><span class="p">></span>
- <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-3"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"container"</span><span class="p">></span>
- <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>
- <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-5"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_c0335d8fcada40ccb0cf1f884bd1a01d-6"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- </pre>
- <p>That’s a <code class="docutils literal"><h1></code> instead of a <code class="docutils literal"><h3></code> like Lanyon does, but hey, it’s the
- right thing to do. If you want to go with an <code class="docutils literal"><h3></code>, just
- change <code class="docutils literal">html_site_title</code> itself.</p>
- <p>And now we more or less have the correct page layout and styles. Except for a
- rather large thing…</p>
- </section><section id="typography"><h2>Typography</h2>
- <p>You can see in the previous screenshot that text still looks quite different in our port: Serif versus Sans-Serif
- content, and the titles have different colors!</p>
- <p>Let’s start with the titles. Here’s how they look in Lanyon:</p>
- <pre class="code html"><a name="rest_code_e2944f60418c413180b6428673e808af-1"></a><span class="p"><</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">"masthead-title"</span><span class="p">></span>
- <a name="rest_code_e2944f60418c413180b6428673e808af-2"></a> <span class="p"><</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">></span>Lanyon<span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_e2944f60418c413180b6428673e808af-3"></a> <span class="p"><</span><span class="nt">small</span><span class="p">></span>A Jekyll theme<span class="p"></</span><span class="nt">small</span><span class="p">></span>
- <a name="rest_code_e2944f60418c413180b6428673e808af-4"></a><span class="p"></</span><span class="nt">h3</span><span class="p">></span>
- </pre>
- <p>Versus our port:</p>
- <pre class="code html"><a name="rest_code_0f80e1aa37524d958a0df59a95befa54-1"></a><span class="p"><</span><span class="nt">h1</span> <span class="na">id</span><span class="o">=</span><span class="s">"brand"</span><span class="p">><</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">></span>
- </pre>
- <p>So, it looks like we will have to fix <code class="docutils literal">html_site_title</code> after all:</p>
- <pre class="code html+mako"><a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-1"></a><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_site_title()"</span><span class="cp">></span>
- <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-2"></a> <span class="p"><</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">></span>
- <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-3"></a> <span class="p"><</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">></span><span class="cp">${</span><span class="n">blog_title</span><span class="cp">}</span><span class="p"></</span><span class="nt">a</span><span class="p">></span>
- <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-4"></a> <span class="p"></</span><span class="nt">h3</span><span class="p">></span>
- <a name="rest_code_f43d7fc8e85b42ef97b6322588feee1d-5"></a><span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
- </pre>
- <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
- "index.tmpl" page, which means it’s a list of blog posts shown one below the
- other. Obviously it’s not doing
- things in the way the Lanyon CSS expects it to. Here’s the original, which you
- can find in Nikola’s source
- code:</p>
- <pre class="code html+mako"><a name="rest_code_e551bc4dba92475db85b839f6885c89f-1"></a><span class="cp">## -*- coding: utf-8 -*-</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-2"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-3"></a><span class="cp"><%</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">/></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-4"></a><span class="cp"><%</span><span class="nb">inherit</span> <span class="na">file=</span><span class="s">"base.tmpl"</span><span class="cp">/></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-5"></a>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-6"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"extra_head"</span><span class="cp">></span>
- <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>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-9"></a> <span class="p"><</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">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-10"></a> <span class="cp">%</span><span class="k"> endif</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-11"></a><span class="cp"></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-12"></a>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-13"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-14"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content_header"</span><span class="cp">></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-15"></a><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"postindex"</span><span class="p">></span>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-17"></a> <span class="p"><</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">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-18"></a> <span class="p"><</span><span class="nt">header</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-19"></a> <span class="p"><</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">><</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">></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"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">h1</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-20"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-21"></a> <span class="p"><</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">><</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">></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"></</span><span class="nt">span</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-22"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">><</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">><</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">></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"></</span><span class="nt">time</span><span class="p">></</span><span class="nt">a</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-24"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">></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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-25"></a> <span class="cp">%</span><span class="k"> endif</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-26"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-27"></a> <span class="p"></</span><span class="nt">header</span><span class="p">></span>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-29"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-31"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-32"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-34"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-35"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-36"></a> <span class="p"></</span><span class="nt">article</span><span class="p">></span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-37"></a><span class="cp">%</span><span class="k"> endfor</span>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-38"></a><span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <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>
- <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>
- <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>
- <a name="rest_code_e551bc4dba92475db85b839f6885c89f-42"></a><span class="cp"></%</span><span class="nb">block</span><span class="cp">></span>
- </pre>
- <p>And this is how it looks after I played with it for a while, making it generate code that looks closer to
- the Lanyon original:</p>
- <pre class="code html+mako"><a name="rest_code_fd5122ac420e47ab84bb494729d69912-1"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content"</span><span class="cp">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-2"></a><span class="cp"><%</span><span class="nb">block</span> <span class="na">name=</span><span class="s">"content_header"</span><span class="cp">></%</span><span class="nb">block</span><span class="cp">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-3"></a><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"posts"</span><span class="p">></span>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-5"></a> <span class="p"><</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">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-6"></a> <span class="p"><</span><span class="nt">header</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-7"></a> <span class="p"><</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">><</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">></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"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">h1</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-8"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-9"></a> <span class="p"><</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">><</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">></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"></</span><span class="nt">span</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-10"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">><</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">><</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">></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"></</span><span class="nt">time</span><span class="p">></</span><span class="nt">a</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-12"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">></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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-13"></a> <span class="cp">%</span><span class="k"> endif</span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-14"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-15"></a> <span class="p"></</span><span class="nt">header</span><span class="p">></span>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-17"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-19"></a> <span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-20"></a> <span class="p"><</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">></span>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-22"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-23"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-24"></a> <span class="p"></</span><span class="nt">article</span><span class="p">></span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-25"></a><span class="cp">%</span><span class="k"> endfor</span>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-26"></a><span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <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>
- <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>
- <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>
- <a name="rest_code_fd5122ac420e47ab84bb494729d69912-30"></a><span class="cp"></%</span><span class="nb">block</span><span class="cp">></span>
- </pre>
- <p>With these changes, it looks… similar?</p>
- <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>
- <figcaption><p>It does!</p>
- </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>
- <pre class="code html+mako"><a name="rest_code_f471988dc16e43429671b09e47f39316-1"></a><span class="cp"><%</span><span class="nb">def</span> <span class="na">name=</span><span class="s">"html_post_header()"</span><span class="cp">></span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-2"></a> <span class="p"><</span><span class="nt">header</span><span class="p">></span>
- <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>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-4"></a> <span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"metadata"</span><span class="p">></span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-5"></a> <span class="p"><</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">><</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">></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"></</span><span class="nt">span</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-6"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"dateline"</span><span class="p">><</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">><</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">></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"></</span><span class="nt">time</span><span class="p">></</span><span class="nt">a</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
- <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>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-8"></a> <span class="p"><</span><span class="nt">p</span> <span class="na">class</span><span class="o">=</span><span class="s">"commentline"</span><span class="p">></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>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-9"></a> <span class="cp">%</span><span class="k"> endif</span>
- <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>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-11"></a> <span class="p"><</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">></span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-12"></a> <span class="cp">%</span><span class="k">endif</span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-13"></a> <span class="p"></</span><span class="nt">div</span><span class="p">></span>
- <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>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-15"></a> <span class="p"></</span><span class="nt">header</span><span class="p">></span>
- <a name="rest_code_f471988dc16e43429671b09e47f39316-16"></a><span class="cp"></%</span><span class="nb">def</span><span class="cp">></span>
- </pre></section><section id="customization"><h2>Customization</h2>
- <p>The original Lanyon theme supports some personalization options. It suggests you do them by tweaking the templates, and
- 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
- version of the theme and it will still "just work".</p>
- <p>Let’s see the color schemes first. They apply easily, just tweak your <code class="docutils literal">body</code> element like this:</p>
- <pre class="code html"><a name="rest_code_bbc2c326094f4118b891e33d8631f56c-1"></a><span class="p"><</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">></span>
- <a name="rest_code_bbc2c326094f4118b891e33d8631f56c-2"></a>...
- <a name="rest_code_bbc2c326094f4118b891e33d8631f56c-3"></a><span class="p"></</span><span class="nt">body</span><span class="p">></span>
- </pre>
- <p>We can tweak <code class="docutils literal">base.tmpl</code> to do just that:</p>
- <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>
- <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-2"></a><span class="p"><</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">></span>
- <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-3"></a><span class="cp">%</span><span class="k">else</span><span class="p">:</span>
- <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-4"></a><span class="p"><</span><span class="nt">body</span><span class="p">></span>
- <a name="rest_code_f4dcd8bf0daf42e1b56dc407750d4511-5"></a><span class="cp">%</span><span class="k">endif</span>
- </pre>
- <p>And then we can put the options in conf.py’s <code class="docutils literal">GLOBAL_CONTEXT</code>:</p>
- <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>
- <a name="rest_code_ab8625d895114acc84ba828d69f39931-2"></a> <span class="s2">"lanyon_subtheme"</span><span class="p">:</span> <span class="s2">"theme-base-08"</span>
- <a name="rest_code_ab8625d895114acc84ba828d69f39931-3"></a><span class="p">}</span>
- </pre>
- <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>
- <figcaption><p>Look at it, all themed up.</p>
- </figcaption></figure><p>Doing the same for layout-reverse, sidebar-overlay and the rest is left as an exercise for the reader.</p>
- </section><section id="bundles"><h2>Bundles</h2>
- <p>If the <code class="docutils literal">USE_BUNDLES</code> option set to True,
- Nikola can put several CSS or JS files together in a larger file, which can
- makes site load faster for some deployments. To do this, your theme needs
- a <code class="docutils literal">bundles</code> file. The file format is a modified
- <a class="reference external" href="https://docs.python.org/3/library/configparser.html">config</a> file with no
- defined section; the basic syntax is:</p>
- <pre class="literal-block">outputfile1.js=
- thing1.js,
- thing2.js,
- ...
- outputfile2.css=
- thing1.css,
- thing2.css,
- ...</pre>
- <p>For the Lanyon theme, it should look like this:</p>
- <pre class="literal-block">assets/css/all.css=
- rst_base.css,
- nikola_rst.css,
- code.css,
- poole.css,
- lanyon.css,
- custom.css,</pre>
- <p><strong>Note:</strong> trailing commas are optional</p>
- <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
- from a CDN and others from a bundle. This is complicated and probably not worth the effort.</p>
- </section><section id="the-end"><h2>The End</h2>
- <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>
- <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>
- <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 <https://github.com/getnikola/nikola></cite> repository on GitHub.</p>
- </section>
- </div>
-
-
- </article>
- </div>
- <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
- <div class="sidebar-module sidebar-module-inset">
- <h4>About</h4>
- <div id="shoutcastdiv">
- <script type="text/javascript">
- refreshdiv();
- </script>
- </div>
- </div>
- <div class="sidebar-module">
- <h4>Links</h4>
- <ol class="list-unstyled">
- <li><a href="http://getbootstrap.com/examples/blog/">Bootstrap Blog Theme</a></li>
- <li><a href="https://getnikola.com/">Nikola</a></li>
- <li><a href="https://twitter.com/mdo">@mdo</a></li>
- <li><a href="https://twitter.com/Kwpolska">@Kwpolska</a></li>
- <li><a href="https://twitter.com/GetNikola">@GetNikola</a></li>
- </ol>
- </div>
-
-
- </div>
- <!--End of body content-->
- </div>
- </div>
- </div>
-
- <footer class="blog-footer" id="footer">
- Contents © 2023 <a href="mailto:contact@riff-radio.org">Riff</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
-
- </footer><script src="../assets/js/all-nocdn.js"></script><!-- fancy dates --><script>
- moment.locale("en");
- fancydates(0, "YYYY-MM-DD HH:mm");
- </script><!-- end fancy dates --><script>
- baguetteBox.run('div#content', {
- ignoreClass: 'islink',
- captions: function(element) {
- return element.getElementsByTagName('img')[0].alt;
- }});
- </script><script type="text/javascript" src="../refresh.js"></script>
- </body>
- </html>
|