[BUG]一个逗号引发的BUG #1030
-
English:Google Search Console alerted me to a problem with my blog: Structured data that can not be parsed, The value type is incorrect Then I use the web tool to detect errors. example site:
The error was caused by a comma The culprit as follows:
The code that generated it is in:
Hope to repair, thank you! 中文:Google Search Console提示我网站存在无法解析的结构化数据-值类型不正确错误。 用网页工具检测出来错误源于一个多出来的
我找到了生成它的代码在layous/partials/templates/schema_json.html的37行。
希望修复,谢谢! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
临时修复方案: import os
def get_all_files(dir):
"""使用listdir循环遍历"""
if not os.path.isdir(dir):
print(dir)
return
dirlist = os.walk(dir)
for root, dirs, files in dirlist:
for file in files:
yield os.path.join(root, file)
path = "./public"
for file in get_all_files(path):
if file.split('.')[-1] == "html":
with open(file, "r+") as f:
text = f.readlines()
for line in range(len(text)):
if " \"itemListElement\": [, " in text[line]:
text[line] = " \"itemListElement\": [\n"
f.seek(0, 0)
f.writelines(text)
f.flush()
print(file, "is OK!")
break 使用方法: python3 fix.py |
Beta Was this translation helpful? Give feedback.
-
Could you share the minimal working example repository to reproduce the issue? |
Beta Was this translation helpful? Give feedback.
-
@BunnySakura Can you try using baseURL as baseURL: https://website.com/ # notice the trailing '/' |
Beta Was this translation helpful? Give feedback.
-
I guess it may caused by some emoji or special character (maybe CJK)... |
Beta Was this translation helpful? Give feedback.
@BunnySakura Can you try using baseURL as