# Buggy code
def slugify_category_name(self, path, lang):
    """Slugify a category name."""
    if lang is None:  # TODO: remove in v8
        utils.LOGGER.warn(
            "ClassifyCategories.slugify_category_name() called without language!"
        )
        lang = ""
    if self.site.config["CATEGORY_OUTPUT_FLAT_HIERARCHY"]:
        path = path[-1:]  # only the leaf
    result = [self.slugify_tag_name(part, lang) for part in path]
    result[0] = self.site.config["CATEGORY_PREFIX"] + result[0]
    if not self.site.config["PRETTY_URLS"]:
        result = ["-".join(result)]
    return result


# Traceback (IndexError)
TaskError - taskid:render_taxonomies:output/index.html
PythonAction Error
Traceback (most recent call last):
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/doit/action.py", line 403, in execute
returned_value = self.py_callable(*self.args, **kwargs)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1426, in render_template
self.rewrite_links(doc, src, context['lang'], url_type)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1440, in rewrite_links
doc.rewrite_links(lambda dst: self.url_replacer(src, dst, lang, url_type), resolve_base_href=False)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/lxml/html/__init__.py", line 622, in rewrite_links
new_link = link_repl_func(link.strip())
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1440, in <lambda>
doc.rewrite_links(lambda dst: self.url_replacer(src, dst, lang, url_type), resolve_base_href=False)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1489, in url_replacer
dst = self.link(dst_url.netloc, dst_url.path.lstrip('/'), lang, **link_kwargs)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1879, in link
url = self.path(*args, is_link=True, **kwargs)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1798, in path
path = self.path_handlers[kind](name, lang, **kwargs)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/misc/taxonomies_classifier.py", line 282, in _taxonomy_path
result = taxonomy.get_path(taxonomy.extract_hierarchy(name), lang, dest_type=dest_type)
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/task/categories.py", line 132, in get_path
return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f] + self.slugify_category_name(classification, lang), 'auto'
File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/task/categories.py", line 125, in slugify_category_name
result[0] = self.site.config['CATEGORY_PREFIX'] + result[0]
IndexError: list index out of range

# Fixed code
def slugify_category_name(self, path, lang):
    """Slugify a category name."""
    if not path:  # Probably used link://category
        utils.LOGGER.error(
            "Invalid link to a category without passing a category name. Probably meant to use category_index?"
        )
        raise ValueError()
    if lang is None:  # TODO: remove in v8
        utils.LOGGER.warn(
            "ClassifyCategories.slugify_category_name() called without language!"
        )
        lang = ""
    if self.site.config["CATEGORY_OUTPUT_FLAT_HIERARCHY"]:
        path = path[-1:]  # only the leaf
    result = [self.slugify_tag_name(part, lang) for part in path]
    result[0] = self.site.config["CATEGORY_PREFIX"] + result[0]
    if not self.site.config["PRETTY_URLS"]:
        result = ["-".join(result)]
    return result