Nested include directive not working

60 views
Skip to first unread message

peibo...@gmail.com

unread,
Jun 2, 2016, 7:40:15 PM6/2/16
to nikola-discuss
Hi,

I configured nikola as the post: https://getnikola.com/creating-a-site-not-a-blog-with-nikola.html

Everything works ok, but I can't use the 'include' directive to include an rst that itself, has an include directive inside.

This is the relevant part of my nikola project tree:
...
├── conf.py
└── pages
        ├── generalnotes.rst
        ├── home.rst
        └── index.rst

index.rst (I striped the headers):
.. include:: pages/home.rst


home.rst:
.. include:: pages/generalnotes.rst

generalnotes.rst:
#. Write your page here
#. test



This is the error nikola throws when building:
InputError: [Errno 2] No such file or directory: 'pages/pages/generalnotes.rst'.

The parser is putting two "pages" directory.

I tried several combinations of paths for the include, but never hits the correct one.


If the contents of home.rst doesn't have an include directive, it works ok.


Is this a bug or the expected way to work, avoiding nested includes?
Any workaround to use nested includes?




Roberto Alsina

unread,
Jun 2, 2016, 7:46:31 PM6/2/16
to nikola-discuss
Well, looks like noone tried that before :-)

It should work if you put "pages/home.rst" in index.rst and "generalnotes.rst" in home.rst

However, that will *NOT* work because when it builds home.rst it will not find generalnotes.rst

A quick and dirty solution is to create a symlink to pages/generalnotes.rst outside pages.

A more complicated solution is to not have things that at the same time are pages and get included in pages.

For example:

index.rst includes pages/home.inc and pages/generalnotes.inc
home.rst includes pages/generalnotes.inc
generalnotes.rst includes pages/generalnotes.inc

--
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.

peibo...@gmail.com

unread,
Jun 3, 2016, 3:40:59 AM6/3/16
to nikola-discuss, ral...@kde.org
Thanks for the quick response Roberto!

Should I file this for improvement in the issue tracker or do you think that it's too much development that doesn't pay the effort?

In the meantime I'll try if any of your proposed workarounds works for me, thanks for the tricks ;)

j.su...@wanadoo.fr

unread,
Nov 20, 2020, 11:10:01 AM11/20/20
to nikola-discuss
Hi ! 

Thanks absolutely for your work, it's incredible ! My site is taking form and it's joyful !
I'm sorry for asking a such important help...

I would like to include a sidebar to all the pages that contains a certain pagekind. My site is in HTML (it's easier for me).
So, if I've well understood, I have to create a new template for those pages ?
Those pages are in /pages/spectacles and I would like that my sidebar imports and render the other spectacles pages. 
How do I proceed ?

Thanks again 

Reply all
Reply to author
Forward
0 new messages