Non-blog home page not rebuilding

19 views
Skip to first unread message

Erik Ritch

unread,
Feb 12, 2020, 6:02:48 PM2/12/20
to nikola-discuss
I've been trying to determine why this is happening, but have been unsuccessful so far.

I am making a site that will be a combination of a static site and a blog.  Following the instructions from https://www.getnikola.com/creating-a-site-not-a-blog-with-nikola.html I have set my config.py to be:

POSTS = (
   
("posts/*.rst", "posts", "post.tmpl"),
   
("posts/*.md", "posts", "post.tmpl"),
   
("posts/*.txt", "posts", "post.tmpl"),
   
("posts/*.html", "posts", "post.tmpl"),
)
PAGES
= (
   
("pages/*.rst", "", "page.tmpl"),
   
("pages/*.md", "", "page.tmpl"),
   
("pages/*.txt", "", "page.tmpl"),
   
("pages/*.html", "", "page.tmpl"),
)

In the directory pages I have a file named index.rst.  Its contents are:

.. title: Home
.. slug: index
.. date: 2020-02-05 08:50:06 UTC-07:00
.. tags:
.. category:
.. link:
.. description:
.. type: text

Test Header
---------------------
Placeholder text for home page

I also have several items in the posts directory.  When I initially issue the command "nikola build" everything happens correctly.  When I make changes to the template files (mainly tweaking things in base.tmpl) and issue that command, the posts update correctly but anything in the pages directory does not update.  If I edit the text of the pages/index.rst file and issue a build command, the file is updated correctly.  Without actually changing the contents of the files inside pages directory, he only way I have of making those files update is to do a "nikola build -a" which is not an ideal option as the site grows.

Is there some setting I am missing that would cause the build to process correctly or, barring that, a way to instruct nikola to just rebuild certain items within the pages directory?

Chris Warrick

unread,
Feb 13, 2020, 2:53:29 AM2/13/20
to Nikola—Discuss
This should work out of the box, and I cannot reproduce with the
following steps.

nikola init -q n
cd n
vim conf.py
# change POSTS, PAGES, INDEX_PATH
nikola new_post -t 'sample post'
vim pages/index.rst
# paste your content verbatim
nikola build
vim pages/index.rst
# add some text
nikola build

The last `nikola build` shows this build log:

Scanning posts........done!
. render_sources:output/index.rst
. render_posts:timeline_changes
. render_posts:cache/pages/index.html
. render_pages:output/index.html
. sitemap:output/sitemap.xml

If this does not work for you, it might be a bug. What versions of
Python and Nikola are you using, and on what OS?

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

Erik Ritch

unread,
Feb 13, 2020, 9:54:04 AM2/13/20
to nikola-discuss
nikola init -q n
cd n
vim conf.py
# change POSTS, PAGES, INDEX_PATH
nikola new_post -t 'sample post'
vim pages/index.rst
# paste your content verbatim
nikola build
vim pages/index.rst
# add some text
nikola build

Now do something along the lines of adding
<script src="/assets/js/jquery-3.4.1.min.js"></script>
to the base_helper.tmpl file under late_load_js() and rebuild.  At least for me, this will cause nikola to rebuild all pages in /posts/ but not in /pages/.  I realize that editing the base template will end up causing all pages on the site to be rebuilt, but if I do nikola build -a to work around this, I end up re-processing all the site's images, which is much slower than just re-processing the pages.

I am using Python 3.8.1 and Nikola 8.0.4 on Windows 10 in a virtualenvironment.  I don't know if it would matter, but I am using PowerShell to run commands.

Roberto Alsina

unread,
Feb 13, 2020, 10:16:11 AM2/13/20
to Nikola—Discuss
No idea about the root cause, but you can force to rebuild parts of the site using -a and a target. Example:

nikola build -a render_pages

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/nikola-discuss/3ed031f0-8666-4f09-8ed7-083ce740ad87%40googlegroups.com.

Chris Warrick

unread,
Feb 13, 2020, 2:22:59 PM2/13/20
to Nikola—Discuss
So, there's a bug with nesting template dependencies in Mako.
page.tmpl inherits from story.tmpl, which includes or inherits many
more files, but the current Mako dependency scanner is not recursive,
so those are not included.

A workaround for this specific case is to use `story.tmpl` as your
template for pages. (We renamed `stories` to `pages` at some point,
but we’re still using that name for some things, and the “real”
template is still `story.tmpl` because the alternative would be quite
messy.)

I opened an issue on GitHub: https://github.com/getnikola/nikola/issues/3349

Chris Warrick

unread,
Feb 13, 2020, 3:11:42 PM2/13/20
to Nikola—Discuss
…and here’s a pull request with a fix (please test, it’s a simple
3-line patch): https://github.com/getnikola/nikola/pull/3350

Erik Ritch

unread,
Feb 13, 2020, 4:10:28 PM2/13/20
to nikola-discuss
That appears to have fixed the problem.  Thanks!

And I'm glad to see that it actually was a bug, not just me missing something.
Reply all
Reply to author
Forward
0 new messages