diff --git a/docs/settings.rst b/docs/settings.rst index 7b78a75f..5551a4bf 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -596,6 +596,9 @@ This would save your articles into something like The location to save a category. The default is ``"category/{slug}.html"``. Set this to ``""`` to disable category pages. Articles still keep their categories, which can be used in URL patterns such as ``ARTICLE_SAVE_AS``. + To disable all category output, also set ``CATEGORIES_SAVE_AS = None`` + and ``CATEGORY_FEED_ATOM = None`` (as well as ``CATEGORY_FEED_RSS``, if + you have enabled it). .. data:: TAG_URL diff --git a/pelican/tests/test_theme.py b/pelican/tests/test_theme.py index 7e0fff6a..742f9b73 100644 --- a/pelican/tests/test_theme.py +++ b/pelican/tests/test_theme.py @@ -184,31 +184,33 @@ class TestTemplateInheritance(LoggedTestCase): try: for theme in ("simple", "notmyidea"): - with self.subTest(theme=theme): - settings = read_settings( - path=None, - override={ - "THEME": theme, - "PATH": content_dir, - "OUTPUT_PATH": self.temp_output, - "CACHE_PATH": self.temp_cache, - "SITEURL": "http://example.com", - "ARTICLE_SAVE_AS": "{category}/{slug}.html", - "CATEGORY_SAVE_AS": False, - "CATEGORIES_SAVE_AS": False, - }, - ) + for category_save_as in ("", None, False): + with self.subTest(theme=theme, CATEGORY_SAVE_AS=category_save_as): + settings = read_settings( + path=None, + override={ + "THEME": theme, + "PATH": content_dir, + "OUTPUT_PATH": self.temp_output, + "CACHE_PATH": self.temp_cache, + "SITEURL": "http://example.com", + "ARTICLE_SAVE_AS": "{category}/{slug}.html", + "CATEGORY_SAVE_AS": category_save_as, + }, + ) - pelican = Pelican(settings=settings) - mute(True)(pelican.run)() + pelican = Pelican(settings=settings) + mute(True)(pelican.run)() - with open( - os.path.join(self.temp_output, "blog", "in-blog.html") - ) as f: - content = f.read() + for page in ("blog/in-blog.html", "categories.html"): + with open(os.path.join(self.temp_output, page)) as f: + content = f.read() - self.assertIn("blog", content) - self.assertNotIn("/category/", content) + self.assertIn("blog", content) + self.assertNotIn("/category/", content) + self.assertFalse( + os.path.exists(os.path.join(self.temp_output, "category")) + ) finally: rmtree(content_dir) diff --git a/pelican/themes/notmyidea/templates/categories.html b/pelican/themes/notmyidea/templates/categories.html index 033f892a..4f64bb60 100644 --- a/pelican/themes/notmyidea/templates/categories.html +++ b/pelican/themes/notmyidea/templates/categories.html @@ -8,7 +8,7 @@