Repository: getnikola/nikola

Issue:
Change the output location for sections
### Environment (if reporting a bug)

**Python Version: 3.6.1**

**Nikola Version: Nikola v7.8.4**

**Operating System: macOS 10.12**

### Description:
With sections, some of the expected behavior appears to be missing as it was with categories. I do see that #2486 is to work on one of the wants I have. For now, I'm fine with setting the metadata for my files.

However, with categories, I have the following set:

~~~
CATEGORY_PATH = 'blog/categories/'
CATEGORY_PREFIX = ''
CATEGORIES_INDEX_PATH = 'blog/categories.html'
~~~

With sections, I don't see such an option available to control the output location. I'd like to have the ability to control the output location as I can with categories.



Discussion:
Sections are a bit special, in that they sometimes assume a relation to the filesystem — they were originally built so that `foo/bar.rst` was in the `foo` section, but also allow specifying those in post metadata.

This should get fixed — and in the long term, we could probably clean up categories vs sections.
Do you just want to move the section indexes/feeds/..., or also the posts in the sections? The placement of the posts in the output tree is already managed by the `POSTS` variable.

Implementing a `SECTION_PATH` which just moves the indexes, feeds etc. around is pretty simple, you just need to modify `ClassifySections.get_path` accordingly in `plugins/task/sections.py`. If you're happy with that, I can do a PR.
@felixfontein 

If I understand the functionality correctly, I believe what I'd be looking for is just moving the section index folders in to my desired location. That is, my posts are already in `/blog/<section>/post-slug`, but it's the `<section name>` index that is not being output in a location I can set.
Yes. A setting `SECTION_PATH` would allow you to place the section indexes where you want them, like in this case probably in `/blog/` as well.
Ah, yes. That is what I am looking for.

Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -584,6 +584,7 @@ def __init__(self, **config):
             'SOCIAL_BUTTONS_CODE': '',
             'SITE_URL': 'https://example.com/',
             'PAGE_INDEX': False,
+            'SECTION_PATH': '',
             'STRIP_INDEXES': False,
             'SITEMAP_INCLUDE_FILELESS_DIRS': True,
             'TAG_PATH': 'categories',
@@ -673,6 +674,7 @@ def __init__(self, **config):
                                       'TAGS_INDEX_PATH',
                                       'CATEGORY_PATH',
                                       'CATEGORIES_INDEX_PATH',
+                                      'SECTION_PATH',
                                       'INDEX_PATH',
                                       'RSS_PATH',
                                       'AUTHOR_PATH',
diff --git a/nikola/plugins/task/sections.py b/nikola/plugins/task/sections.py
--- a/nikola/plugins/task/sections.py
+++ b/nikola/plugins/task/sections.py
@@ -98,7 +98,7 @@ def get_classification_friendly_name(self, section, lang, only_last_component=Fa
 
     def get_path(self, section, lang, dest_type='page'):
         """Return a path for the given classification."""
-        result = [_f for _f in [section] if _f]
+        result = [_f for _f in [self.site.config['SECTION_PATH'](lang), section] if _f]
         if dest_type == 'rss':
             return result + ['rss.xml'], 'never'
         return result, 'always'


Test patch: