seo
seo copied to clipboard
Error: Authors can be empty!
I get the following error:
[...]
File "...seo\seo_enhancer\html_enhancer\article_schema_creator.py", line 17, in __init__
self._author = author.name
AttributeError: 'NoneType' object has no attribute 'name'
The reason for the error is: The implicit assumption that the object author is not empty is wrong because there's the option to have no authors for an article.
Proposed fix for this line:
def __init__(self, author, title, category, date, logo, image, sitename):
if author:
self._author = author.name
else:
self._author=''
self._title = title
self._category = category.name
self._publication_date = date
self._logo = logo
self._image = image
self._sitename = sitename
Hi @Sogolumbo, thanks for raising this.
To fix this, I would go for this here:
if self._author:
schema_article["author"] = {"@type": "Person", "name": self._author.name}
Same issue for category
.
Feel free to open a PR with according tests if you want to contribute :)
Hello,
Was it fixed? Doesn't look like it but maybe I'm wrong. I use Pelican but I don't set Author because I'm the only one writing, and I'll be interested to look at this particular case.
Let me know!