简体   繁体   English

谷歌搜索结构化数据中允许使用哪些字符

[英]what characters are allowed in google search structured data

I want to use google rich search results with structured data.我想使用带有结构化数据的谷歌富搜索结果。

I'm confused about what characters the description tag can take.我对描述标签可以采用哪些字符感到困惑。

For example, I want to use例如,我想使用

{ description: "this is a backslash \\ here" }

I know JSON does not allow a backslash without escaping我知道 JSON 不允许在不转义的情况下使用反斜杠

My question is if I replace the \\ with \\' like this我的问题是我是否像这样用 \\' 替换 \\

{ description: "this is a backslash \\ here" }

Will this display \\ on the rendered page or will it display '\\'这会在呈现的页面上显示 \\ 还是会显示 '\\'

Google will parse the data using the json rules so will most likely see it as a backslash. Google 将使用 json 规则解析数据,因此很可能会将其视为反斜杠。

A way to get an idea is to run a comment like this in your browsers console.获得想法的一种方法是在浏览器控制台中运行这样的评论。

console.log({ description: "this is a backslash \u005C here" });

This also results in the backslash:这也会导致反斜杠:

console.log({ description: "this is a backslash \\ here" });

Google does do its own post processing of the strings it sees.谷歌确实对它看到的字符串进行了自己的后期处理。 eg it will most likely remove any html and some emojis.例如,它很可能会删除任何 html 和一些表情符号。

And sometimes even Google has a bug in the way they encode/decode that can cause strange outputs.有时甚至谷歌在编码/解码的方式上也有一个错误,可能会导致奇怪的输出。

The only way to know for certain is to test.确定的唯一方法是测试。 But I think you will be fine as in this case the encoding is dealt with via json.但我认为你会没事的,因为在这种情况下编码是通过 json 处理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM