Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Here's a very big gun, there's your foot: PHP support in Nikola

I am a ve­ry big pro­po­nent of sta­tic si­te ge­ne­ra­tor­s. I would not ha­ve bo­the­red wri­ting Niko­la othe­rwi­se. But the­re is alwa­ys that fee­ling that ma­y­be the­re is so­me li­ttle thing whi­ch is hard to im­ple­men­t, like a con­tact for­m.

And le­t's fa­ce it, the ea­siest way to sol­ve so­me of tho­se things is by sti­cking a few li­nes of PHP in your HT­M­L.

So, if you rea­lly want to, you can do it. I thi­nk Niko­la (gi­thub mas­te­r) is the first sta­tic si­te ge­ne­ra­tor that su­ppor­ts php co­de. He­re's ho­w:

  1. Add php to your pa­ge_­com­pi­lers (be­cau­se I wi­ll ne­ver put it the­re by de­faul­t):

    post_compilers = {
        "rest": ('.txt', '.rst'),
        "markdown": ('.md', '.mdown', '.markdown'),
        "textile": ('.textile',),
        "txt2tags": ('.t2t',),
        "bbcode": ('.bb',),
        "wiki": ('.wiki',),
        "ipynb": ('.ipynb',),
        "html": ('.html', '.htm'),
        "php": ('.php'),
  2. Add php pos­ts or pa­ges to your pos­t_­pa­ges:

    post_pages = (
        ("posts/*.txt", "posts", "post.tmpl", True),
        ("posts/*.php", "posts", "post.tmpl", True),
        ("stories/*.txt", "stories", "story.tmpl", False),
        ("stories/*.php", "stories", "story.tmpl", False),
  3. Crea­te a php pos­t:

    nikola new_post posts/foo.php
  4. Put php in the­re:

    .. date: 2013/04/16 09:57:09
    .. title: php test
    .. slug: foo
    Print "Hello, World!";

Build the si­te as usua­l, and you should end up wi­th a pa­ge wi­th PHP ex­ten­sio­n, that has that PHP in the "con­ten­t" area, so it wi­ll fo­llow your si­te's the­me. Of cour­se you can't do things like add HTTP hea­ders and su­ch, but he­y, read the ti­tle.

Nikola version 5.4.4 is out!

Ye­s, ver­sion 5.4.4 of Niko­la, my sta­tic si­te/­blog ge­ne­ra­tor is just pu­blis­hed at the usual pla­ce, in­clu­ding the fo­llo­wing im­pro­ve­men­ts:


  • New Ja­­pa­­ne­­se tran­s­­la­­tio­­n.

  • Niko­­­la che­­ck exis­­ts wi­­th 1 if the­­re is an error

  • New HI­­DE_UN­­TRAN­S­­LA­TE­­D_­­PO­S­­TS op­­tion that en­­su­­res you do­­n't ha­­ve mixe­­d-­­lan­­gua­­ge pa­­ges (Is­­sue #373)

  • New the­­me "si­­te-­­pla­­ne­­toi­­d" for use wi­­th the pla­­ne­­toid plu­­gi­n.

  • New 're­­ti­­re­­d' tag for po­s­­ts that should no lo­n­­ger be in fee­­d­s.


  • Added post da­­ta as a up­­to­­­da­­te che­­ck for mus­­ta­­che (Is­­sue #456)

  • Re­­build post pa­­ges when the po­s­­t's tran­s­­la­­tion list chan­­ges (Is­­sue #458)

  • Han­d­­le "-h" (Is­­sue #460)

  • Added co­­­rrect help for co­n­­so­­­le co­­­m­­mand (Is­­sue #460)

  • Es­­ca­­pe twi­­tte­r­­card da­­ta (Is­­sue #452)

  • Added mis­­sing "twi­­tte­r­­ca­r­­d" in sto­­­ry te­m­­pla­­te

  • Added su­­pport for pe­­r-­­lan­­gua­­ge tags (Is­­sue #450)

  • Fix wrong pa­­th spli­­tting (Is­­sue #434)

  • Re­­me­m­­ber lo­­­ca­­le even when se­­t_­­lo­­­ca­­le fai­­les (Is­­sue #446)

  • De­­co­­­de pa­­th ar­­gu­­ment in new_­­post (Is­­sue #442)

  • ta­sk_i­n­­dexes had mis­­sing co­n­­fig de­­pen­­den­­cies (Is­­sue #441)

  • Re­­mo­­­ved bo­­­gus li­nks to sli­­des asse­­ts that we­­re re­­mo­­­ved

  • Co­m­­press­ed fi­­les we­­re seen as unk­­no­­wn by "niko­­­la che­­ck"

  • lo­­­cal sea­r­­ch and mus­­ta­­che plu­­gins must be di­s­a­­bled by de­­fault (Is­­sue #437)

  • Avoid fai­­lu­­re if the­­re are no tags and USE_­G­­ZIP is ena­­bled (Is­­sue #439)

  • Fix as­­pect ra­­tio de­­te­c­­tion in Vi­­meo vi­­deos (Is­­sue #440)

  • Blo­­­gger im­­po­r­­ter was pa­s­­sing wrong op­­tions to "niko­­­la ini­­t" (Is­­sue #408)

Boneshaker (The Clockwork Century, #1)

Cover for Boneshaker (The Clockwork Century, #1)


Nice steam­punk, even if half the physics make no sense what­so­ev­er (like, the blight be­ing heav­ier than air yet it flow­ing up from the ground, and ev­ery­one liv­ing un­der­ground).

I am go­ing to fol­low the se­ries at least.

Every Day (Every Day, #1)

Cover for Every Day (Every Day, #1)


A very ten­der book. I like that it does­n't try to ex­plain the pe­cu­liar na­ture of the main char­ac­ter. I'll have my kid read it when he's 12 or so.

Contents © 2000-2024 Roberto Alsina