Skip to content

Commit 86aee59

Browse files
committedMay 29, 2015
some basic proofreading and fixes
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 56f593b commit 86aee59

File tree

1 file changed

+129
-116
lines changed

1 file changed

+129
-116
lines changed
 

Diff for: ‎docs/creating-a-theme.txt

+129-116
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
Nikola is a static site and blog generator. So is Jekyll. While I like what we have done with Nikola,
1111
I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.
1212

13-
This document is an attempt at making it easier for 3rd parties (that means you people! ;-) to
13+
This document is an attempt at making it easier for 3rd parties (that means *you* people! ;-) to
1414
create themes. Since I **suck** at designing websites, I asked for opinions on themes to port,
15-
and got some feedback. Since this is **Not So Hard (TM)** I will try to make time to port a few
15+
and got some feedback. Since this is **Not So Hard™**, I will try to make time to port a few
1616
and see what happens.
1717

18-
Today's theme is `Lanyon <https://github.com/poole/lanyon>`__ which is written by `@mdo <https://twitter.com/mdo>`__
18+
Todays theme is `Lanyon <https://github.com/poole/lanyon>`__ which is written by `@mdo <https://twitter.com/mdo>`__
1919
and released under a MIT license, which is liberal enough.
2020

21-
So, let's get started.
21+
So, lets get started.
2222

2323
Checking It Out
2424
---------------
2525

2626
The first step in porting a theme is making the original theme work. Lanyon is awesome in that its
27-
`github prohject <https://github.com/poole/lanyon>`__ is a full site!
27+
`GitHub project <https://github.com/poole/lanyon>`__ is a full site!
2828

2929
So::
3030

@@ -40,30 +40,30 @@ So::
4040
# Look at it
4141
jekyll serve & google-chrome http://localhost:4000
4242

43-
If you want, you can also see it in action at http://lanyon.getpoole.com/
43+
If you do not want to install Jekyll, you can also see it in action at http://lanyon.getpoole.com/
4444

4545
Some things jump to my mind:
4646

47-
1) This is one fine looking theme
48-
2) Very clear and readable
49-
3) Nice hidden navigation-thingy
47+
1. This is one fine looking theme
48+
2. Very clear and readable
49+
3. Nice hidden navigation-thingy
5050

51-
Also, from looking at `the project's README <https://github.com/poole/lanyon/blob/master/README.md>`__
51+
Also, from looking at `the projects README <https://github.com/poole/lanyon/blob/master/README.md>`__
5252
it supports some nice configuration options:
5353

54-
1) color scheme themes
55-
2) reverse layout
56-
3) sidebar overlay instead of push
57-
4) show the sidebar open by default, or based on a page's metadata
54+
1. color schemes
55+
2. reverse layout
56+
3. sidebar overlay instead of push
57+
4. show the sidebar open by default, or based on a pages metadata
5858

59-
Let's try to make all those nice things survive the porting.
59+
Lets try to make all those nice things survive the porting.
6060

6161
Starting From Somewhere
6262
-----------------------
6363

6464
Nikola has a nice, clean, base theme from which you can start when writing your own theme.
6565
Why start from that instead of from a clean slate? Because theme inheritance is going to save you a ton of work,
66-
that's why. If you start from scratch you won't be able to build **anything** until you have a bunch of
66+
thats why. If you start from scratch you wont be able to build **anything** until you have a bunch of
6767
templates written. Starting from base, you just need to hack on the things you **need** to change.
6868

6969
First, we create a site with some content in it. We’ll use the ``nikola init`` wizard (with the ``--demo`` option) for that::
@@ -104,27 +104,27 @@ First, we create a site with some content in it. We’ll use the ``nikola init``
104104
[2015-05-28T16:02:08Z] INFO: init: See README.txt in that folder for more information.
105105

106106
Then, we create an empty theme inheriting from base. This theme will use Mako templates. If you prefer Jinja2,
107-
then you should use base-jinja instead::
107+
then you should use ``base-jinja`` instead::
108108

109109
$ cd lanyon-port/
110110
$ mkdir themes
111111
$ mkdir themes/lanyon
112112
$ echo base > themes/lanyon/parent
113113

114-
Edit conf.py and set ``THEME = 'lanyon'``. Also set ``USE_BUNDLES = False`` (just do it for now, we'll get to bundles later).
114+
Edit conf.py and set ``THEME = 'lanyon'``. Also set ``USE_BUNDLES = False`` (just do it for now, well get to bundles later).
115115

116116
You can now build that site using ``nikola build`` and it will look like this:
117117

118-
.. figure:: /images/lanyon-0.thumbnail.png
119-
:target: /images/lanyon-0.png
118+
.. figure:: https://getnikola.com/images/lanyon-0.thumbnail.png
119+
:target: https://getnikola.com/images/lanyon-0.png
120120

121121
This is just the base theme.
122122

123123
Basic CSS
124124
---------
125125

126-
The next step is to know exactly how Lanyon's pages work. To do this, we read its HTML.
127-
First let's look at the head element:
126+
The next step is to know exactly how Lanyons pages work. To do this, we read its HTML.
127+
First lets look at the head element:
128128

129129
.. code:: html
130130

@@ -184,22 +184,23 @@ see something fairly similar:
184184

185185

186186
Luckily, since this is all under a very liberal license, we can just copy these CSS files into
187-
Nikola, adapting a little the paths so that they follow
188-
our conventions::
187+
Nikola, adapting the paths a little so that they follow our conventions::
189188

190189
$ mkdir -p themes/lanyon/assets/css
191190
$ cp ../lanyon/public/css/lanyon.css themes/lanyon/assets/css/
192191
$ cp ../lanyon/public/css/poole.css themes/lanyon/assets/css/
193192

194-
Notice I am *not* copying ``syntax.css``? That's because Nikola handles that styles for syntax highlighting
193+
Notice I am *not* copying ``syntax.css``? Thats because Nikola handles that styles for syntax highlighting
195194
in a particular way, using a setting called ``CODE_COLOR_SCHEME`` where you can configure
196195
what color scheme the syntax highlighter uses. You can use your own ``assets/css/code.css`` if you
197-
don't like the provided ones.
196+
dont like the provided ones.
198197

199-
But how do I tell **our** lanyon theme to use those CSS files instead of whatever it's using now?
200-
By giving our theme its own base_helper.tmpl
198+
But how do I tell **our** lanyon theme to use those CSS files instead of whatever its using now?
199+
By giving our theme its own base_helper.tmpl.
201200

202-
That file is a **template** used to generate parts of the pages. It's large and complicated but we don't need to change a lot of it. First, get it from `Nikola's source code <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base_helper.tmpl>`__ and put a copy in ``themes/lanyon/templates/base_helper.tmpl``::
201+
That file is a **template** used to generate parts of the pages. It’s large and
202+
complicated but we don’t need to change a lot of it. First, get it from
203+
`Nikola’s source code <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base_helper.tmpl>`__ and put a copy in ``themes/lanyon/templates/base_helper.tmpl``::
203204

204205
$ mkdir themes/lanyon/templates
205206
$ curl https://raw.githubusercontent.com/getnikola/nikola/master/nikola/data/themes/base/templates/base_helper.tmpl > themes/lanyon/templates/base_helper.tmpl
@@ -244,17 +245,17 @@ And we will change it so it uses the lanyon styles instead of theme.css (again,
244245
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400">
245246
</%def>
246247

247-
.. figure:: /images/lanyon-1.thumbnail.png
248-
:target: /images/lanyon-1.png
248+
.. figure:: https://getnikola.com/images/lanyon-1.thumbnail.png
249+
:target: https://getnikola.com/images/lanyon-1.png
249250

250-
You may say this looks like crap. Don't worry, we are just starting :-)
251+
You may say this looks like crap. Dont worry, we are just starting :-)
251252

252253
Page Layout
253254
-----------
254255

255256
This is trickier but should be no problem for people with a basic understanding of HTML and a desire to make a theme!
256257

257-
Lanyon's content is split in two parts: a sidebar and the rest. The sidebar looks like this (shortened for comprehension):
258+
Lanyons content is split in two parts: a sidebar and the rest. The sidebar looks like this (shortened for comprehension):
258259

259260
.. code:: html
260261

@@ -280,7 +281,7 @@ So, a plain body, with an input element that controls the sidebar, a div which i
280281
Inside that, div.sidebar-item for items, and a nav with "navigational links". This is followed by the "masthead" and
281282
the content itself, which we will look at in a bit.
282283

283-
If we look for the equivalent code in Nikola's side, we see this:
284+
If we look for the equivalent code in Nikolas side, we see this:
284285

285286
.. code:: html
286287

@@ -297,9 +298,9 @@ If we look for the equivalent code in Nikola's side, we see this:
297298
So Nikola has the "masthead" above the nav element, and uses list elements in nav instead of bare links.
298299
Not all that different is it?
299300

300-
Let's make it lanyon-like! We will need 2 more templates: `base.tmpl <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base.tmpl>`__ and `base_header.tmpl <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base_header.tmpl>`__. Get them and put them in your ``themes/lanyon/templates`` folder.
301+
Lets make it lanyon-like! We will need 2 more templates: `base.tmpl <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base.tmpl>`__ and `base_header.tmpl <https://github.com/getnikola/nikola/blob/master/nikola/data/themes/base/templates/base_header.tmpl>`__. Get them and put them in your ``themes/lanyon/templates`` folder.
301302

302-
Let's look at ``base.tmpl`` first. It's short and nice, it looks like a webpage without
303+
Lets look at ``base.tmpl`` first. Its short and nice, it looks like a webpage without
303304
all the interesting stuff:
304305

305306
.. code:: html+mako
@@ -377,13 +378,15 @@ So, first, lets change that base template to be more lanyon-like:
377378
</body>
378379
</html>
379380

380-
.. figure:: /images/lanyon-2.thumbnail.png
381-
:target: /images/lanyon-2.png
381+
.. figure:: https://getnikola.com/images/lanyon-2.thumbnail.png
382+
:target: https://getnikola.com/images/lanyon-2.png
382383

383-
And that's after I exposed the sidebar by clicking on an invisible widget!
384+
And thats after I exposed the sidebar by clicking on an invisible widget!
384385

385-
One problem, which causes that yellow color in the sidebar is a CSS conflict. We are loading rst.css which specifies
386-
the background color of ``div.sidebar`` which is more specific than lanyon.css, which specifies for ``.sidebar`` alone.
386+
One problem, which causes that yellow color in the sidebar is a CSS conflict.
387+
We are loading ``rst.css`` which specifies
388+
the background color of ``div.sidebar`` which is more specific than
389+
``lanyon.css``, which specifies for ``.sidebar`` alone.
387390

388391
There are many ways to fix this, I chose to change lanyon.css to also use div.sidebar:
389392

@@ -415,14 +418,14 @@ Another problem is that the contents of the nav element are wrong. They are not
415418
</nav>
416419
</%def>
417420

418-
**Note: this means this theme will not support submenus in navigation. If you want that, I'll happily take a patch.**
421+
**Note: this means this theme will not support submenus in navigation. If you want that, Ill happily take a patch.**
419422

420-
.. figure:: /images/lanyon-3.thumbnail.png
421-
:target: /images/lanyon-3.png
423+
.. figure:: https://getnikola.com/images/lanyon-3.thumbnail.png
424+
:target: https://getnikola.com/images/lanyon-3.png
422425

423426
Starting to see a resemblance?
424427

425-
Now let's look at the content. In Lanyon, this is how the "main" content looks:
428+
Now lets look at the content. In Lanyon, this is how the "main" content looks:
426429

427430
.. code:: html
428431

@@ -450,8 +453,9 @@ Now let's look at the content. In Lanyon, this is how the "main" content looks:
450453
</body>
451454
</html>
452455

453-
Everything inside the "container content" div is ... the content. The rest is a masthead with the site title
454-
and at the bottom a label for the sidebar's toggle. Easy to do in ``base.tmpl`` (only showing relevant part):
456+
Everything inside the "container content" div is… the content. The rest is a masthead with the site title
457+
and at the bottom a label for the sidebar toggle. Easy to do in ``base.tmpl``
458+
(only showing the relevant part):
455459

456460
.. code:: html+mako
457461

@@ -479,100 +483,105 @@ and at the bottom a label for the sidebar's toggle. Easy to do in ``base.tmpl``
479483
</body>
480484
</html>
481485

482-
.. figure:: /images/lanyon-4.thumbnail.png
483-
:target: /images/lanyon-4.png
486+
.. figure:: https://getnikola.com/images/lanyon-4.thumbnail.png
487+
:target: https://getnikola.com/images/lanyon-4.png
484488

485489
Getting there!
486490

487-
The sidebar looks bad because of yet more CSS conflicts with rst.css. By adding some extra styling in lanyon.css, it will look better.
491+
The sidebar looks bad because of yet more CSS conflicts with ``rst.css``. By
492+
adding some extra styling in ``lanyon.css``, it will look better.
488493

489494
.. code:: css
490495

491496
/* Style and "hide" the sidebar */
492-
div.sidebar,.sidebar {
493-
position: fixed;
494-
top: 0;
495-
bottom: 0;
496-
left: -14rem;
497-
width: 14rem;
498-
visibility: hidden;
499-
overflow-y: auto;
500-
padding: 0;
501-
margin: 0;
502-
border: none;
503-
font-family: "PT Sans", Helvetica, Arial, sans-serif;
504-
font-size: .875rem; /* 15px */
505-
color: rgba(255,255,255,.6);
506-
background-color: #202020;
507-
-webkit-transition: all .3s ease-in-out;
508-
transition: all .3s ease-in-out;
497+
div.sidebar, .sidebar {
498+
position: fixed;
499+
top: 0;
500+
bottom: 0;
501+
left: -14rem;
502+
width: 14rem;
503+
visibility: hidden;
504+
overflow-y: auto;
505+
padding: 0;
506+
margin: 0;
507+
border: none;
508+
font-family: "PT Sans", Helvetica, Arial, sans-serif;
509+
font-size: .875rem; /* 15px */
510+
color: rgba(255,255,255,.6);
511+
background-color: #202020;
512+
-webkit-transition: all .3s ease-in-out;
513+
transition: all .3s ease-in-out;
509514
}
510515

511-
Also, the accessibility link on top is visible when it should not. That's because we removed "theme.css" from the base theme, and with it, we lost a couple of classes. We can add them in lanyon.css, along with others used by other
516+
Also, the accessibility link on top is visible when it should not. That’s
517+
because we removed ``theme.css`` from the base theme, and with it, we lost a
518+
couple of classes. We can add them in ``lanyon.css``, along with others used by other
512519
pieces of the site:
513520

514521
.. code:: css
515522

516523
.sr-only {
517-
position: absolute;
518-
width: 1px;
519-
height: 1px;
520-
padding: 0;
521-
margin: -1px;
522-
overflow: hidden;
523-
clip: rect(0, 0, 0, 0);
524-
border: 0;
524+
position: absolute;
525+
width: 1px;
526+
height: 1px;
527+
padding: 0;
528+
margin: -1px;
529+
overflow: hidden;
530+
clip: rect(0, 0, 0, 0);
531+
border: 0;
525532
}
526533

527534
.sr-only-focusable:active,
528535
.sr-only-focusable:focus {
529-
position: static;
530-
width: auto;
531-
height: auto;
532-
margin: 0;
533-
overflow: visible;
534-
clip: auto;
536+
position: static;
537+
width: auto;
538+
height: auto;
539+
margin: 0;
540+
overflow: visible;
541+
clip: auto;
535542
}
536543

537544
.breadcrumb {
538-
padding: 8px 15px;
539-
margin-bottom: 20px;
540-
list-style: none;
545+
padding: 8px 15px;
546+
margin-bottom: 20px;
547+
list-style: none;
541548
}
542549

543550
.breadcrumb > li {
544-
display: inline-block;
545-
margin-right: 0;
546-
margin-left: 0;
551+
display: inline-block;
552+
margin-right: 0;
553+
margin-left: 0;
547554
}
548555

549556
.breadcrumb > li:after {
550-
content: ' / ';
551-
color: #888;
557+
content: ' / ';
558+
color: #888;
552559
}
553560

554561
.breadcrumb > li:last-of-type:after {
555-
content: '';
556-
margin-left: 0;
562+
content: '';
563+
margin-left: 0;
557564
}
558565

559566
.thumbnails > li {
560-
display: inline-block;
561-
margin-right: 10px;
567+
display: inline-block;
568+
margin-right: 10px;
562569
}
563570

564571
.thumbnails > li:last-of-type {
565-
margin-right: 0;
572+
margin-right: 0;
566573
}
567574

568575

569-
.. figure:: /images/lanyon-5.thumbnail.png
570-
:target: /images/lanyon-5.png
576+
.. figure:: https://getnikola.com/images/lanyon-5.thumbnail.png
577+
:target: https://getnikola.com/images/lanyon-5.png
571578

572579
Little by little, things look better.
573580

574-
One clear problem is that the title "Lanyon A Jekyll theme" is set in the theme itself. We don't do that sort of things
575-
in Nikola, we have settings for that. So, let's use it. There is a ``html_site_title`` function in ``base_helper.tmpl`` which is just the thing. So we change base.tmpl to use it:
581+
One clear problem is that the title "Lanyon · A Jekyll theme" is set in the
582+
theme itself. We don’t do that sort of thing in Nikola, we have settings for
583+
that. So, let’s use them. There is a ``html_site_title`` function in
584+
``base_helper.tmpl`` which is just the thing. So we change base.tmpl to use it:
576585

577586
.. code:: html+mako
578587

@@ -583,18 +592,20 @@ in Nikola, we have settings for that. So, let's use it. There is a ``html_site_t
583592
</div>
584593
</div>
585594

586-
That's a H1 instead of a H3 like Lanyon does, but hey, it's the right thing to do. If you want to go with an H3, just
595+
That’s a ``<h1>`` instead of a ``<h3>`` like Lanyon does, but hey, it’s the
596+
right thing to do. If you want to go with an ``<h3>>`, just
587597
change ``html_site_title`` itself.
588598

589-
And now we more or less have the correct page layout and styles. Except for a rather large thing...
599+
And now we more or less have the correct page layout and styles. Except for a
600+
rather large thing…
590601

591602
Typography
592603
----------
593604

594605
You can see in the previous screenshot that text still looks quite different in our port: Serif versus Sans-Serif
595606
content, and the titles have different colors!
596607

597-
Let's start with the titles. Here's how they look in Lanyon:
608+
Lets start with the titles. Heres how they look in Lanyon:
598609

599610
.. code:: html
600611

@@ -619,9 +630,11 @@ So, it looks like we will have to fix ``html_site_title`` after all:
619630
</h3>
620631
</%def>
621632

622-
As for the actual content, that's not in any of the templates we have seen so far. The page you see is an
623-
"index.tmpl" page, which means it's a list of blog posts shown one below the other. Obviously it's not doing
624-
things in the way the Lanyon CSS expects it to. Here's the original, which you can find in Nikola's source
633+
As for the actual content, that’s not in any of the templates we have seen so far. The page you see is an
634+
"index.tmpl" page, which means it’s a list of blog posts shown one below the
635+
other. Obviously it’s not doing
636+
things in the way the Lanyon CSS expects it to. Here’s the original, which you
637+
can find in Nikola’s source
625638
code:
626639

627640
.. code:: html+mako
@@ -708,14 +721,14 @@ the Lanyon original:
708721

709722
Some of the typography problems were caused by loading ``lanyon.css`` and ``poole.css`` in the wrong order all the way back at the beginning of this tutorial.
710723

711-
With these changes, it looks ... similar?
724+
With these changes, it looks similar?
712725

713-
.. figure:: /images/lanyon-6.thumbnail.png
714-
:target: /images/lanyon-6.png
726+
.. figure:: https://getnikola.com/images/lanyon-6.thumbnail.png
727+
:target: https://getnikola.com/images/lanyon-6.png
715728

716729
It does!
717730

718-
Similar changes (basically adding classnames to elements) needed to be done in ``post_header.tmpl``:
731+
Similar changes (basically adding class names to elements) needed to be done in ``post_header.tmpl``:
719732

720733
.. code:: html+mako
721734

@@ -740,10 +753,10 @@ Customization
740753
-------------
741754

742755
The original Lanyon theme supports some personalization options. It suggests you do them by tweaking the templates, and
743-
you *can* do that in Nikola's port also. But we prefer to use options for that, so that you can get a later, better
756+
you *can* also do that in the Nikola port. But we prefer to use options for that, so that you can get a later, better
744757
version of the theme and it will still "just work".
745758

746-
Let's see the color schemes first. They apply easily, just tweak your ``body`` element like this:
759+
Lets see the color schemes first. They apply easily, just tweak your ``body`` element like this:
747760

748761
.. code:: html
749762

@@ -761,20 +774,20 @@ We can tweak ``base.tmpl`` to do just that:
761774
<body>
762775
%endif
763776

764-
And then we can put the options in conf.py's ``GLOBAL_CONTEXT``:
777+
And then we can put the options in conf.pys ``GLOBAL_CONTEXT``:
765778

766779
.. code:: python
767780

768781
GLOBAL_CONTEXT = {
769782
"lanyon_subtheme": "theme-base-08"
770783
}
771784

772-
.. figure:: /images/lanyon-7.thumbnail.png
773-
:target: /images/lanyon-7.png
785+
.. figure:: https://getnikola.com/images/lanyon-7.thumbnail.png
786+
:target: https://getnikola.com/images/lanyon-7.png
774787

775788
Look at it, all themed up.
776789

777-
Doing the same for layout-reverse, sidebar-overlay and the rest is left as an excercise for the reader.
790+
Doing the same for layout-reverse, sidebar-overlay and the rest is left as an exercise for the reader.
778791

779792
Bundles
780793
-------
@@ -795,6 +808,6 @@ from a CDN and others from a bundle. This is complicated and probably not worth
795808
The End
796809
-------
797810

798-
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.
811+
And thats it, thats a whole theme. Eventually, once people start using it, they will notice small broken details, which will need handling one at a time.
799812

800813
This theme should be available in http://themes.getnikola.com#lanyon and you can see it in action at https://themes.getnikola.com/v7/lanyon/index.html

0 commit comments

Comments
 (0)
Please sign in to comment.