Nikola page generation question

29 views
Skip to first unread message

Milan Kosir

unread,
Dec 5, 2017, 6:09:39 PM12/5/17
to nikola-discuss
Hi, I'm looking for good static site generator and Nikola looks like decent and fast tool,
and what I really like is incremental build.

I would like to know if it is possible in Nikola to create pages from yaml data file,
something like this in jekyll... For example if I have a list ot table of products and I would
like to create one page for every product from list (based on template).

Thanks in advance for any reply!

George Leslie-Waksman

unread,
Dec 5, 2017, 6:36:02 PM12/5/17
to nikola-...@googlegroups.com
It should be possible to write a nikola plugin to do that sort of processing.

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Milan Kosir

unread,
Dec 5, 2017, 6:40:55 PM12/5/17
to nikola-discuss
Thanks for reply!

Chris Warrick

unread,
Dec 5, 2017, 6:41:20 PM12/5/17
to Nikola—Discuss
Nikola supports data files, and then you could make a custom template or use shortcode stuff to make use of them.

(More details in the manual.)
--
Chris Warrick <https://chriswarrick.com/>

--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discuss+unsubscribe@googlegroups.com.

Milan Kosir

unread,
Dec 6, 2017, 2:43:34 AM12/6/17
to nikola-discuss
Thanks again :)

I would be grateful if you could explain to me a little bit more in detail.
Suppose I have yaml file with data for users (name, address, bio, etc):
  • html page with all users (one template)
  • html page for every user (second template)

How can I achieve this with use of shortcodes?

Thanks in advance for support!

Milan Kosir

unread,
Dec 6, 2017, 2:47:41 AM12/6/17
to nikola-discuss
+ user pages should be linked from page with all users, so if you click on user on page with all users,
browser should load detail page with that user.

Thanks.

Anton Akhmerov

unread,
Dec 19, 2017, 3:46:24 PM12/19/17
to nikola-discuss
Coincidentally I have just encountered the same problem.

My solution was to implement a custom plugin (which is much less robust than the built-in tools). Here it goes: https://pastebin.com/PMtV6YBu

However I have a question to the devs as well: the drawback of my plugin is that it is specific to .rst files, however I'd like to also do templating of .html files. Is it possible to implement a single plugin for all file types that would be run before the compile plugins?

Further, Chris Warrick mentioned using shortcodes. From the documentation it seemed that the shortcodes are substituted after compiling the html, is that right?

Cheers.

Chris Warrick

unread,
Dec 19, 2017, 4:04:09 PM12/19/17
to Nikola—Discuss
The shortcode I have in mind is a template shortcode — one that is
based on Mako/Jinja2 templates, and that has access to data files
<https://getnikola.com/handbook.html#the-global-context-and-data-files>.
It could display anything from the data file attached to a posts, or
data files that are global to the site.

Note that you would need an input file (.rst/.md/.html) for every
user. Another approach would be a custom compiler plugin that
understands YAML files (and treats them as pages).

https://github.com/getnikola/plugins/blob/master/v7/pkgindex_compiler/pkgindex_compiler.py
(there are also _scan and _zip, not necessary for your project)
https://github.com/getnikola/plugins/tree/master/site (→templates, →pages)

And the two sites built using that infrastructure:
https://plugins.getnikola.com/
https://themes.getnikola.com/
Yes, that’s true. Shortcodes work in most markups (including reST,
Markdown, HTML). And we have built-in support for the thing you want,
via shortcodes:
https://getnikola.com/handbook.html#template-based-shortcodes

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Milan Kosir

unread,
Dec 19, 2017, 4:33:34 PM12/19/17
to nikola-discuss
Honestly I don't understand what the heck are you talking about, guys :)
But thanks a lot for reply!
I'll check all these links and see if I can get what I need.
I'll be back! :)
Reply all
Reply to author
Forward
0 new messages