--- /home/knut/.pyenv/versions/pelican/lib/python3.8/site-packages/pelican/readers.py.old 2021-01-16 21:53:36.342103461 +0900 +++ /home/knut/.pyenv/versions/pelican/lib/python3.8/site-packages/pelican/readers.py 2021-01-16 22:06:47.699735450 +0900 @@ -210,17 +210,18 @@ " Using 'en' instead.", lang_code) self._language_code = 'en' - def _parse_metadata(self, document, source_path): + def _parse_metadata(self, document, source_path, nowarning_about_missing_title): """Return the dict containing document metadata""" formatted_fields = self.settings['FORMATTED_FIELDS'] output = {} - if document.first_child_matching_class(docutils.nodes.title) is None: - logger.warning( - 'Document title missing in file %s: ' - 'Ensure exactly one top level section', - source_path) + if nowarning_about_missing_title is False: + if document.first_child_matching_class(docutils.nodes.title) is None: + logger.warning( + 'Document title missing in file %s: ' + 'Ensure exactly one top level section', + source_path) for docinfo in document.traverse(docutils.nodes.docinfo): for element in docinfo.children: @@ -272,8 +273,12 @@ parts = pub.writer.parts content = parts.get('body') - metadata = self._parse_metadata(pub.document, source_path) - metadata.setdefault('title', parts.get('title')) + title = parts.get('title') + if title: + metadata = self._parse_metadata(pub.document, source_path, nowarning_about_missing_title=False) + metadata.setdefault('title', title) + else: + metadata = self._parse_metadata(pub.document, source_path, nowarning_about_missing_title=True) return content, metadata