diff --git a/pelican/contents.py b/pelican/contents.py index 11459f77..bce45135 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -172,7 +172,7 @@ class Content: def _has_valid_mandatory_properties(self) -> bool: """Test mandatory properties are set.""" for prop in self.mandatory_properties: - if not hasattr(self, prop): + if not hasattr(self, prop) or getattr(self, prop) in (None, ""): logger.error( "Skipping %s: could not find information about '%s'", self, prop ) diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index 4e48e594..780770ea 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -734,6 +734,16 @@ class TestArticle(TestBase): custom_article = Article(**article_kwargs) self.assertEqual("custom", custom_article.template) + def test_empty_title_invalid(self): + # articles with empty title should be invalid + settings = get_settings() + article_kwargs = self._copy_page_kwargs() + article_kwargs["metadata"]["title"] = "" + article_kwargs["metadata"]["date"] = datetime.datetime.now() + article_kwargs["settings"] = settings + article = Article(**article_kwargs) + self.assertFalse(article.is_valid()) + def test_slugify_category_author(self): settings = get_settings() settings["SLUG_REGEX_SUBSTITUTIONS"] = [