Automating posts with nikola

32 views
Skip to first unread message

spinp...@gmail.com

unread,
Nov 21, 2016, 5:36:29 AM11/21/16
to nikola-discuss
Hello,

I am trying to use nikola on my website blog which posts updates of a particular data stream 2-3 times a day. I will be generating posts in the .rst format using Jinja2.
I tried creating a new file in the 'posts' folder but when I did `nikola build`, I got the following error:

ERROR: Nikola: Two posts are trying to generate posts/test/index.html: posts/tester.rst and
posts/test.rst                                                                                                                        
[2016-11-21T10:28:35Z] ERROR: Nikola: Two posts are trying to generate posts/test/index.rst: posts/tester.rst and posts/test.rst


How can I solve this issue.
Specifically how can I automate posts on the server without typing `nikola new_post` ?

Roberto Alsina

unread,
Nov 21, 2016, 5:44:39 AM11/21/16
to nikola-discuss
The problem there is you have the same slug "test" for 2 posts in the same folder, so they are trying to generate the same files. Just use different slugs.

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

spinp...@gmail.com

unread,
Nov 21, 2016, 5:59:16 AM11/21/16
to nikola-discuss, ral...@kde.org
Thanks, that solved the issue. Nikola is awesome!

Dave

unread,
Nov 21, 2016, 3:11:58 PM11/21/16
to nikola-discuss, ral...@kde.org
Should this really be an error that stops the build?

I think it would be much better if Nikola was more lenient and handled these, perhaps with a warning, but just simply appending _2 (or perhaps a config pattern).

That's what I'd want to happen. I have posts coming in from many sources, trying to get multiple writers to submit their content in REST is hard enough, so usually the slug is just auto-generated from the title (to lower case, replace " " with "_" etc. I don't care if the titles / slugs are the same.

In the end I hacked up a plugin to try and keep nikola happy:

duplicate slugs
missing category and template refers to category
an empty line within meta calls
and a few other things that had me swearing late at night on a Friday :)

and a whole load of typical mistakes I see which can break nikola. The above error message was useful, this is not always the case, don't get me started on :


ERROR: Task generation 'render_site' has duplicated definition of 'render_tags:output/category/index.html'


which is never anything to do with tags or category and seems to just be the first error triggered when something goes wrong .

I know the whole mantra of "fail hard fail early", but I reckon most of the time the problem is known and can be detected and fixed quietly. Someone used to debugging will probably get to the bottom of the issue, but probably some are turned off. Might even mean less support for you guys which is always a good thing right?

Perhaps an option so those who want infuriation can have it, those of us who are happy to assume Nikola knows best, can have that as well :)

Roberto Alsina

unread,
Nov 21, 2016, 5:05:37 PM11/21/16
to nikola-...@googlegroups.com
On Mon, Nov 21, 2016 at 5:12 PM Dave <prosr...@gmail.com> wrote:
Should this really be an error that stops the build?


If you don't want it to stop the build, use the -c option.
 
I think it would be much better if Nikola was more lenient and handled these, perhaps with a warning, but just simply appending _2 (or perhaps a config pattern).

We already have too many configuration options :-(

Also, it's somewhat bad to do that because it means the URL of a post / page is not determined by itself but by whether there are collisions with other posts/pages, and may change in the future. Changing the URL of things is very, very bad.
 

That's what I'd want to happen. I have posts coming in from many sources, trying to get multiple writers to submit their content in REST is hard enough, so usually the slug is just auto-generated from the title (to lower case, replace " " with "_" etc. I don't care if the titles / slugs are the same.

Then don't even have a slug field! If there isn't one, Nikola will use something derived from the filename, which you probably already handle to avoid collisions.
 
In the end I hacked up a plugin to try and keep nikola happy:

duplicate slugs
missing category and template refers to category
an empty line within meta calls
and a few other things that had me swearing late at night on a Friday :)

and a whole load of typical mistakes I see which can break nikola. The above error message was useful, this is not always the case, don't get me started on :


ERROR: Task generation 'render_site' has duplicated definition of 'render_tags:output/category/index.html'


which is never anything to do with tags or category and seems to just be the first error triggered when something goes wrong .


Hmmmm I have not seen that one. Could you create a sample failing site?
 
I know the whole mantra of "fail hard fail early", but I reckon most of the time the problem is known and can be detected and fixed quietly.

When that's the case, and the solution is unique, sure. If the solution implies a judgment call... not so much.
 
Someone used to debugging will probably get to the bottom of the issue, but probably some are turned off. Might even mean less support for you guys which is always a good thing right?

If there is an error message that is not informative and doesn't explain how to fix the root cause, I am happy to work on making it better so there are fewer errors in the future.
 

Perhaps an option so those who want infuriation can have it, those of us who are happy to assume Nikola knows best, can have that as well :)


Nikola very strongly doesn't know best :-)
 

prosrcmedia

unread,
Nov 21, 2016, 5:52:37 PM11/21/16
to nikola-...@googlegroups.com
All good points but:

>> If you don't want it to stop the build, use the -c option

don't want to be ignoring all errors :)



>> Also, it's somewhat bad to do that because it means the URL of a post /
>> page is not determined by itself but by whether there are collisions with
>> other posts/pages, and may change in the future. Changing the URL of things
>> is very, very bad.

This is very true. Probably an example of my usual, solve one problem
make two more


>>> ERROR: Task generation 'render_site' has duplicated definition of
>>> 'render_tags:output/category/index.html'
>>>
>>> which is never anything to do with tags or category and seems to just be
>>> the first error triggered when something goes wrong .
>>>
>> Hmmmm I have not seen that one. Could you create a sample failing site?

I haven't had it for a couple of weeks, since I made the plugin to fix a
few regular errors I was having (and since stopped working on nikola
late at night actually). Also I don't think it is a default nikola
problem, I was hacking around with themes and plugins and post files
whilst testing. The issue was always my fault completely.

But if I come across it again, or have some time to try and cause it
again I'll provide the details


>> Nikola very strongly doesn't know best :-)

If you have a spare moment and can work on a "mind reader" plugin, I for
one would appreciate it ;-)

Jean Jordaan

unread,
Mar 17, 2018, 1:10:09 AM3/17/18
to nikola-discuss
It's rather silly generating multilingual pages in different directories (`/en/slug`, `/th/slug`), but having to manually disambiguate slugs (to avoid the "_Two posts are trying to generate_" issue).

Is that really how it works?

Chris Warrick

unread,
Mar 17, 2018, 6:56:41 AM3/17/18
to Nikola—Discuss
On 17 March 2018 at 06:10, Jean Jordaan <jean.j...@gmail.com> wrote:
> It's rather silly generating multilingual pages in different directories (`/en/slug`, `/th/slug`), but having to manually disambiguate slugs (to avoid the "_Two posts are trying to generate_" issue).
>
> Is that really how it works?

No, it isn’t. You are supposed to create `posts/slug.rst` and
`posts/slug.th.rst` (assuming English as default). Slug issues won’t
happen if you do that.

PS. please create new threads for new questions.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
Reply all
Reply to author
Forward
0 new messages