Skip to content
Browse files
Fix #2651 -- append file name if new_post gets directory name
Signed-off-by: Chris Warrick <>
  • Loading branch information
Kwpolska committed Feb 15, 2017
1 parent 95d869d commit 8bd206cb798aea61af79dedf1b072270dcf267a3
Showing with 13 additions and 3 deletions.
  1. +3 −1 CHANGES.txt
  2. +2 −1 docs/manual.txt
  3. +8 −1 nikola/plugins/command/
@@ -4,8 +4,10 @@ New in master

* Append file name (generated from title) if ``nikola new_post``
receives directory name as path (Issue #2651)
* Add ``META_GENERATOR_TAG`` option in allowing the meta generator
to be disabled if needed. (Issue #2628)
tag to be disabled (Issue #2628)
``HTML_TIDY_EXECUTABLE`` to configure executables for built-in filters.
@@ -567,7 +567,8 @@ The ``new_post`` command supports some options:

The optional ``path`` parameter tells Nikola exactly where to put it instead of guessing from your config.
So, if you do ``nikola new_post posts/random/foo.txt`` you will have a post in that path, with
"foo" as its slug.
"foo" as its slug. You can also provide a directory name, in which case Nikola
will append the file name for you (generated from title).

The ``-d, --date-path`` option automates creation of ``year/month/day`` or
similar directory structures. It can be enabled on a per-post basis, or you can
@@ -311,7 +311,14 @@ def _execute(self, options, args):
path = path.decode(sys.stdin.encoding)
except (AttributeError, TypeError): # for tests
path = path.decode('utf-8')
slug = utils.slugify(os.path.splitext(os.path.basename(path))[0],
if os.path.isdir(path):
# If the user provides a directory, add the file name generated from title (Issue #2651)
slug = utils.slugify(title,
pattern = os.path.basename(entry[0])
suffix = pattern[1:]
path = os.path.join(path, slug + suffix)
slug = utils.slugify(os.path.splitext(os.path.basename(path))[0],

if isinstance(author, utils.bytes_str):

0 comments on commit 8bd206c

Please sign in to comment.