Skip to main content

Ralsina.Me — Roberto Alsina's website

Creating a Site (Not a Blog) with Nikola

One of the most fre­quent ques­tions I get about Niko­la is "but how do I cre­ate a site that's not a blog?". And of course, that's be­cause the doc­u­men­ta­tion is heav­i­ly blog-ori­ent­ed. This doc­u­ment will change that ;-)

Since it start­ed, Niko­la has had the ca­pa­bil­i­ties to cre­ate gener­ic sites. For ex­am­ple, Niko­la's own site is a fair­ly gener­ic one. Let's go step by step on how you can do some­thing like that.

As usual when starting a nikola site, you start with nikola init which creates a empty semi-configured site:

$ nikola init mysite
Created empty site at mysite.

Then we go into the new mysite folder, and make the needed changes in the conf.py configuration file:

##############################################
# Configuration, please edit
##############################################


# Data about this site
BLOG_AUTHOR = "Roberto Alsina"
BLOG_TITLE = "Not a Blog"
# This is the main URL for your site. It will be used
# in a prominent link
SITE_URL = "http://notablog.ralsina.me"
BLOG_EMAIL = "ralsina@kde.org"
BLOG_DESCRIPTION = "This is a demo site (not a blog) for Nikola."

#
# Some things in the middle you don't really need to change...
#

post_pages = (
    ("pages/*.txt", "", "story.tmpl", False),
)

And now we are ready to cre­ate our first page:

$ nikola new_post -p
Creating New Post
-----------------

Enter title: index
Your post's text is at:  pages/index.txt

We can now build and pre­view our site:

$ nikola build
Scanning posts.done!
.  render_site:output/categories/index.html
.  render_sources:output/index.txt
.  render_rss:output/rss.xml
:
:
: [Much more of the same]

$ nikola serve
Serving HTTP on 127.0.0.1 port 8000 ...

And you can see your (very emp­ty) site in http://lo­cal­host:8000

So, what's in that pages/index.txt file?

.. title: index
.. slug: index
.. date: 2013/03/01 10:26:17
.. tags:
.. link:
.. description:


Write your post here.

Title is the page title, slug is the name of the generated HTML file (in this case it would be index.html) the date doesn't matter much in not-blogs, same for tags and link. Description is useful for SEO purposes if you care for that.

And be­low, the con­tent. By de­fault you are ex­pect­ed to use re­Struc­tured text but Niko­la sup­ports a ton of for­mat­s, in­clud­ing Mark­down, plain HTM­L, BB­Code, Wik­i, and Tex­tile.

So, let's give the page a nicer ti­tle, and some fake con­tent. Since the de­fault Niko­la theme (called "site") is based on boot­strap you can use any­thing you like from it:

.. title: Welcome To The Fake Site
.. slug: index
.. date: 2013/03/01 10:26:17
.. tags:
.. link:
.. description: Fake Site version 1, welcome page!


.. class:: hero-unit span6

.. admonition:: This is a Fake Site

    It pretends to be about things, but is really just an example.
    So, don't click this button, it leads nowhere.

    .. class:: btn

    Click Me!


.. class:: span5

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris non nunc turpis.
Phasellus a ullamcorper leo. Sed fringilla dapibus orci eu ornare. Quisque
gravida quam a mi dignissim consequat. Morbi sed iaculis mi. Vivamus ultrices
mattis euismod. Mauris aliquet magna eget mauris volutpat a egestas leo rhoncus.
In hac habitasse platea dictumst. Ut sed mi arcu. Nullam id massa eu orci
convallis accumsan. Nunc faucibus sodales justo ac ornare. In eu congue eros.
Pellentesque iaculis risus urna. Proin est lorem, scelerisque non elementum at,
semper vel velit. Phasellus consectetur orci vel tortor tempus imperdiet. Class
aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos
himenaeos.

[And more in the same vein]

And that's it. You will want to change the SIDEBAR_LINKS option to create a reasonable "menu" for your site, you will want to hack the theme (check nikola help bootswatch_theme for a quick & dirty solution), and you may want to add a blog later on, for company news or whatever.

You can see the fin­ished site in http://no­tablog.ralsi­na.me and its full con­fig­u­ra­tion in //ralsi­na.me/list­ings/no­tablog/­con­f.py.html

I hope this was help­ful!

Constellation Games

Cover for Constellation Games

Review:

Re­mind­ed me of Year Ze­ro, which is a very good thing.

Very in­ter­est­ing point of view about a first con­tac­t, even if it's of course, in may ways, a trans­par­ent nerd self­-re­al­iza­tion fan­ta­sy.

Spe­cial­ly loved the at­tempts at de­scrib­ing games just on the edge of in­com­pre­hen­si­bil­i­ty. If they were made less un­der­stand­able, there's no plot. If they were more hu­man, then it's not fun.

Go­ing to read the ex­tra free con­tent avail­able at the book's site.

Load Testing Nikola

Niko­la gen­er­ates stat­ic sites, so load test­ing it is not very in­ter­est­ing, ex­cept as a bench­mark for the dif­fer­ence be­tween stat­ic and dy­nam­ic sites.

To­day I was told about blitz.io and since a quick test is free, I thought, why not? The re­sult is quite im­pres­sive: a cheap VP­S, us­ing gatling as a web server, which is al­most con­fig­u­ra­tion-free and not meant for ex­treme­ly high load­s, can han­dle rough­ly 9 mil­lion dai­ly hit­s.

Let me say that again: 9 mil­lion hits. On a un­con­fig­ured $5 serv­er. Here's the re­port

How much tun­ing does it take for a word­press in­stance to serve that? On what hard­ware?

And that's on­ly half the pic­ture. Not on­ly are Niko­la's stat­ic pages in­cred­i­bly light on your server, we have al­so spent a lot of ef­fort try­ing to make in­di­vid­u­al pages load fast, for a bet­ter us­er ex­pe­ri­ence. Some of the tech­niques used for fast-load­ing sites are:

  • Us­ing we­bas­sets to bun­­dle CSS and JS in­­­to sin­­gle files.

  • Au­­to­­mat­ic sup­­port for CDNs for the com­­mon JS li­braries

  • Sup­­port for tran­s­­par­en­t­­ly us­ing HT­M­L/C­SS/JS/Im­age com­pres­­sion tools

So, if you try some­thing like YS­low! on a Niko­la site, it will give you a score of rough­ly 93 up to 98 (out of 100) de­pend­ing on your web­serv­er con­fig­u­ra­tion.

BTW: I re­al­ly want to get that up to 100. Re­al­ly want it

So, re­mem­ber, if your site can be served stat­i­cal­ly, it's go­ing to be cheap­er, faster, safer. And if you ev­er get 9 mil­lion hits a day, it will be avail­able.

Disclaimer:

Blitz.io is send­ing me a t-shirt ;-)

Captain Vorpatril's Alliance (Vorkosigan Saga, #15)

Cover for Captain Vorpatril's Alliance (Vorkosigan Saga, #15)

Review:

Re­mem­ber when the Vorkosi­gan books were about some­one hav­ing an ad­ven­ture, and char­ac­ters do­ing in­ter­est­ing things?

Well, that was then. Now these books tend to be more about the char­ac­ters re­mem­ber­ing pre­vi­ous ad­ven­tures, and run­ning in­to char­ac­ters that did in­ter­est­ing things in oth­er book­s.

Fi­nal­ly around the 60% mark, a sort of plot is put in mo­tion, and some things hap­pen. But the stakes seem low, the risk seems lit­tle.

I adore the Vorkosi­gan se­ries, but this book is not good.

Colón Al Colón

Span­ish on­ly, sor­ry!


Un lu­gar común en la char­la políti­ca ar­genti­na es "se gas­tan la pla­ta en Fút­bol para To­dos en vez de cosas im­por­tan­tes". Siem­pre me hi­zo un poco de ruido, a ver si me sale ex­plicar por qué.

Para em­pezar parte de una jer­ar­quía de pri­or­i­dades, hay cosas más im­por­tantes que otras, y una de el­las, el fút­bol, es menos im­por­tante que al­gu­na, y por lo tan­to no habría que gas­tar dinero en el­la. Eso es un ar­gu­men­to de cal­i­dad du­dosa, ya que no se gas­ta dinero úni­ca­mente en la cosa más im­por­tante.

Imag­ináte que en tu casa se lle­ga a un con­sen­so, y de­ci­den que la cosa más im­por­tante es la co­mi­da, y a con­tin­uación gas­tan el 100% de to­dos los suel­dos en co­mi­da. Eso parece ra­zon­able? No. Las pri­or­i­dades de­finen en qué se gas­ta más o menos y en al­gún ca­so si hay que cor­tar al­go se cor­tará lo menos im­por­tan­te, pero "A es más im­por­tante que B" no es, a pri­or­i, mo­ti­vo para no gas­tar na­da en B.

Lo que sí sería mo­ti­vo para no gas­tar na­da en fút­bol sería que provo­cara un daño. Por ejem­plo, a mí me gus­taría que el go­b­ier­no no gas­tara un pe­so en ejérci­to, porque no veo que sir­va para nada, e históri­ca­mente (dig­amos los úl­ti­mos cien años) el ejérci­to ar­genti­no y sus aledaños han si­do clara­mente un fac­tor neg­a­ti­vo en la vi­da de la nación, des­de bom­bardear Buenos Aires, a in­vadir Malv­inas, der­ro­car go­b­ier­nos, etc. Aún si sos, ponéle, an­tiper­o­nista, y creés que Perón es la causa de to­dos los males... bueno, el viene del ejérci­to.

Pero no creo que el fút­bol sea al­go ma­lo en sí mis­mo. No es co­mo si es­tu­vier­an ga­s­tan­do la gui­ta en petar­dos. En­ton­ces, com­paré­moslo con al­go sim­i­lar. Com­paré­mos a Colón (de San­ta Fe) con el Colón.

En el fon­do, tan­to el fút­bol (y Colón) co­mo el Colón, son en­treten­imien­to. Son cir­co. Los pre­supuestos son com­pa­ra­bles (den­tro de un or­den de mag­ni­tud, o sea, no es que el fút­bol cues­ta cien ve­ces más). Si bi­en el ori­gen de los fon­dos es dis­tin­to, para este análi­sis no hace difer­en­ci­a, es pla­ta públi­ca, pla­ta de im­puestos.

¿Qué nos dá el Colón, que no nos dá Colón? Nos dá ópera y bal­let. For­mas artís­ti­cas que al 93% (por­centa­je in­ven­ta­do) no les mueve un pe­lo. Colón (no el colón) nos dá fút­bol, apre­ci­a­do por un por­centa­je mu­cho may­or de la población.

El Colón nos da, di­je, esas for­mas artís­ti­cas, apre­ci­adas en gran parte por gente que, seamos sin­ceros, po­dría pa­gar por el­las. Sí, hay una can­ti­dad de gente de clase me­dia y ba­ja que va al Colón. Tam­bién hay un mon­tón de oli­gar­cas que van a ver es­pec­tácu­los pa­ga­dos por los im­puestos de gente a la que no le in­tere­sa en lo más mín­i­mo pa­gar por el­los. El Colón sub­ven­ciona el en­treten­imien­to de los ri­cos.

Sí, tam­bién es cier­to que Colón (el equipo) provee fút­bol, que mucha gente (yo in­cluí­do) no tiene ningún in­terés en ver (e­spe­cial­mente a Colón), pero ca­da fin de se­m­ana más gente apre­cia un par­tido del Sa­balero que la au­di­en­cia de me­dia tem­po­ra­da de líri­ca.

¿En­ton­ces, si uno hiciera un cál­cu­lo util­i­tar­i­o, por qué habría que pa­gar por el Colón para pocos y no por Colón, para mu­chos? ¿Por qué nadie pi­de que cier­ren el Colón?

¿No hay una hipocre­sía ahí? ¿No hay un juicio de que el Colón es cul­tura mien­tras que el fút­bol no lo es? ¿Es ése en re­al­i­dad el ar­gu­men­to?

Yo, per­sonal­mente, nun­ca fuí a ver un es­pec­tácu­lo al Colón, igual que nun­ca fuí a ver a Colón (de­bo haber ido a ver a Unión 8 ve­ces en 30 años, con la con­sigu­iente de­silusión pa­ter­na), pero sé que hay gente que apre­cia ca­da una de esas cosas, y sé que el "prob­le­ma" de no apre­cia­r­las es mío. No de el­los. No es­tá mal que les guste la líri­ca, o el bal­let, o el Tor­neo Clausura.

Y no es­tá mal que un go­b­ier­no le dé a la gente al­go que les guste. No es­tá mal que el Colón le dé a los porteños mo­ti­vo de orgul­lo porque tienen ese teatro ahí, y a al­gunos el plac­er de ir a ver una fun­ción. No es­tá mal que Colón le dé a los sa­baleros mo­ti­vo de orgul­lo porque es­tán en primer­a, y el plac­er de ir a ver un par­tido. Y no es­tá mal que un go­b­ier­no pon­ga pla­ta para es­o.

Aunque eso no sea tan im­por­tante co­mo el Gar­ra­han, o co­mo repavi­men­tar una ru­ta, o co­mo pa­gar un policía. Por lo menos no la es­tán ga­s­tan­do en el ejérci­to.

Aclaración

Ya que veo por co­men­tar­ios en dis­tin­tos lu­gares que no se en­tiende del todo, aclaro un po­quito. Me la fu­ma en pi­pa el FP­T, y me la fu­ma en pi­pa el Colón. Lit­eral­mente, si los dos de­sa­parecier­an mañana, no me daría cuen­ta. Lo úni­co que este artícu­lo es, es un in­ten­to de jun­tar y con­trastar dos cosas dis­tin­tas y mostrar el pare­ci­do, para ver si se puede pen­sar en el­las de una man­era dis­tin­ta.

Hay una larga tradi­ción de us­ar este re­cur­so cuan­do se es­cribe un en­say­o. No es orig­i­nal en lo más mín­i­mo. Es di­ver­tido ver la gente con es­puma en la bo­ca porque oso es­bozar una de­fen­sa (¡ni siquier­a!) del gas­to en FP­T. Piensen que tran­quil­a­mente po­drían ver este mis­mo ar­tic­u­lo co­mo un ataque con­tra el gas­to en el Colón y demás cul­tura pre­ten­ciosa y eli­tista. Di­ver­tido, pero no es­tim­u­lante. Por eso es­ta aclaración.


Contents © 2000-2024 Roberto Alsina