Can't create new posts: `nikola new_post`: Missing date in file posts/2.md

179 views
Skip to first unread message

Skyler Daché

unread,
Aug 23, 2017, 3:44:32 PM8/23/17
to nikola-discuss
Hi there, I'm trying to create new posts with nikola but it's not working.  When I create my post file and run `nikola new post`, I get several python errors saying it couldn't find a date or failed to parse an empty string as a date.  I'm probably doing something wrong but I dont't know what.  Does anyone know what the problem might be?  I tried entering the date in several different formats but it always gives me the same errors/stack trace.

date strings I tried:
2017-08-23
2017-08-23T19:41:13+00:00
2017-08-23 19:41:13 UTC
2017-08-23T15:41:42-04:00
2017-08-23 15:41:42 America/New_York

system setup:
I'm running this in a python3 virtual environment on a Fedora 26 system (my home computer)
After setting up the virtualenv I ran these commands:
pip install --upgrade setuptools pip wheel
pip install --upgrade Nikola[extras]
nikola init --demo my_first site
cd my_first site && nikola build


my post file (2.md):
title: My First Blog Post with markdown
slug: my-first-blog-post-wit-markdown
date: 2017-08-23
tags: blog,website,test
category: test

Testing testing, is this working?

command and stack trace:
(venv) [skyler@new-host-2 posts]$ nikola new_post -f markdown 2.md
Creating New Post
-----------------

Title: My First Blog Post With Markdown
Scanning posts..[2017-08-23T19:32:44Z] ERROR: Nikola: Missing date in file posts/2.md
[2017-08-23T19:32:44Z] ERROR: scan_posts: Error reading post posts/2.md
[2017-08-23T19:32:44Z] ERROR: Nikola: Error reading timeline
Traceback (most recent call last):
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/utils.py", line 926, in to_datetime
    value = dateutil.parser.parse(value)
  File "/home/skyler/venv/lib64/python3.6/site-packages/dateutil/parser.py", line 1182, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/home/skyler/venv/lib64/python3.6/site-packages/dateutil/parser.py", line 562, in parse
    raise ValueError("String does not contain a date.")
ValueError: String does not contain a date.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/post.py", line 210, in __init__
    self.date = to_datetime(self.meta[self.default_lang]['date'], tzinfo)
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/utils.py", line 931, in to_datetime
    raise ValueError('Unrecognized date/time: {0!r}'.format(value))
ValueError: Unrecognized date/time: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/skyler/venv/lib64/python3.6/site-packages/doit/doit_cmd.py", line 167, in run
    return command.parse_execute(args)
  File "/home/skyler/venv/lib64/python3.6/site-packages/doit/cmd_base.py", line 120, in parse_execute
    return self.execute(params, args)
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/plugin_categories.py", line 134, in execute
    return self._execute(options, args)
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/plugins/command/new_post.py", line 349, in _execute
    self.site.scan_posts()
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/nikola.py", line 2178, in scan_posts
    timeline = p.plugin_object.scan()
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/plugins/misc/scan_posts.py", line 101, in scan
    destination_base=destination_translatable
  File "/home/skyler/venv/lib64/python3.6/site-packages/nikola/post.py", line 217, in __init__
    raise ValueError(msg)
ValueError: Missing date in file posts/2.md

Chris Warrick

unread,
Aug 23, 2017, 4:03:47 PM8/23/17
to Nikola—Discuss
You're using the Markdown meta data format, which requires special configuration. Have you enabled that support in conf.py?

The standard format would look like this, perhaps inside a HTML comment:

.. date: 2017-08-23 20:00:00 UTC

(All of your date strings look okay to me.)

--
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.
For more options, visit https://groups.google.com/d/optout.

Skyler Daché

unread,
Aug 23, 2017, 7:02:05 PM8/23/17
to nikola-...@googlegroups.com
I checked my conf.py file and found this (I figured I shouldn't change it):

# What Markdown extensions to enable?
# You will also get gist, nikola and podcast because those are
# done in the code, hope you don't mind ;-)
# Note: most Nikola-specific extensions are done via the Nikola plugin system,
#       with the MarkdownExtension class and should not be added here.
# The default is ['fenced_code', 'codehilite']
MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code', 'markdown.extensions.codehilite', 'markdown.extensions.extra']

If I am supposed to change it, how do I know what to change it to?  Or what do I need to change?

--
You received this message because you are subscribed to a topic in the Google Groups "nikola-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nikola-discuss/cnWiCIEyblQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nikola-discuss+unsubscribe@googlegroups.com.

Chris Warrick

unread,
Aug 24, 2017, 3:21:16 AM8/24/17
to Nikola—Discuss
On 24 August 2017 at 01:01, Skyler Daché <skyber...@gmail.com> wrote:
> I checked my conf.py file and found this (I figured I shouldn't change it):
>
> # What Markdown extensions to enable?
> # You will also get gist, nikola and podcast because those are
> # done in the code, hope you don't mind ;-)
> # Note: most Nikola-specific extensions are done via the Nikola plugin
> system,
> # with the MarkdownExtension class and should not be added here.
> # The default is ['fenced_code', 'codehilite']
> MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code',
> 'markdown.extensions.codehilite', 'markdown.extensions.extra']
>
> If I am supposed to change it, how do I know what to change it to? Or what
> do I need to change?

https://getnikola.com/handbook.html#markdown-metadata

> Markdown Metadata only works in Markdown files, and requires the markdown.extensions.meta extension (see MARKDOWN_EXTENSIONS). The exact format is described in the markdown metadata extension docs.

If you want to use Markdown Metadata, add 'markdown.extensions.meta'
to MARKDOWN_EXTENSIONS in your conf.py.

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

Skyler Daché

unread,
Aug 24, 2017, 12:03:15 PM8/24/17
to nikola-...@googlegroups.com
Thanks a lot for clearing that up! It's working fine now

Reply all
Reply to author
Forward
0 new messages