TBB*_*TBB 4 uri microdata data-structures json-ld iri
我想知道使用片段标识符格式引用实体是否更好/适当 - 基本上是通过在名称前插入哈希
[url] + # + [name] => http://example.com/page/#webPage
编辑:
根据来自慷慨和伟大的@Unor的回复,我添加了这个编辑以试图限制我的查询范围并澄清我遇到的主要问题.我还删除了大部分原始问题(大约95%)(事后看来)我觉得有缺点:1.我的核心问题; 2.对未来读者的好处.
这是我的问题:
在微数据的itemid和json-ld的@id值开始时手动键入哈希的做法是否有效?
以下是我更详细的问题:
我可以在微数据的itemid值和json-ld的@id值中插入HASH符号(#),以便通过正确有效地使用片段标识符来创建有效的结果URI吗?
所以,如果这是在网页上:
<div itemscope itemtype="http://www.schema.org/Person" itemid="#joe"></div>
Run Code Online (Sandbox Code Playgroud)
或者,如果这也在网页上:
{"@context":"http://schema.org",
"@type":"Person",
"@id":"#Joe"}
Run Code Online (Sandbox Code Playgroud)
我知道他们会被读到这样的uri(假设消费者的相对构造是谷歌的结构化数据测试工具):
http://www.example.com/page#joe
Run Code Online (Sandbox Code Playgroud)
那是uri:
有效的uri; 和
是否正确使用片段标识符(HASH)?
允许在请求URI时检索有关实体的描述是一种很好的做法(请参阅语义Web的Cool URI:1.在Web上).
通过使用哈希URI,您可以免费获得此功能:
http://example.com/flower 代表关于花的文件http://example.com/flower#this 代表花http://example.com/flower#this,您将获得有关它的文档通过使用Slash URI,您必须自己实现重定向(状态码为303):
http://example.com/flower 代表关于花的文件http://example.com/flower/this 代表花http://example.com/flower/this,您将303重定向到关于它的URI (请参阅示例)因此,在不了解您的后端的情况下,我建议使用Hash URI,因为它通常更容易设置.
(我不确定你对"网页实体"究竟是什么意思,但只是为了确保:哈希URI应该用于"真实世界对象",而不是文档.)
编辑(针对您更新的问题):
是的,您可以通过仅指定片段组件(以a开头)在itemid和@id(示例)中提供哈希URI #.
所以在带有URL的文档中http://example.com/foobar,这四个语句生成相同的Hash URI(http://example.com/foobar#this):
<article itemscope itemtype="http://voc.example.net/Example" itemid="#this">
</article>
<article itemscope itemtype="http://voc.example.net/Example" itemid="http://example.com/foobar#this">
</article>
<script type="application/ld+json">
{
"@context": "http://voc.example.net/",
"@type": "Example",
"@id": "#this"
}
</script>
<script type="application/ld+json">
{
"@context": "http://voc.example.net/",
"@type": "Example",
"@id": "http://example.com/foobar#this"
}
</script>
Run Code Online (Sandbox Code Playgroud)
(是的,您的示例URI有效;这里是片段组件可能包含的字符.)
笔记:
itemid="#joe"和"@id":"#Joe"解决不同的URI(j对J)./page/#joe对比/page#joe); 查询组件很重要(页面/page?foo=bar会创建哈希URI /page?foo=bar#joe,而不是/page#joe); 如果主持人有www.或没有事; URI方案很重要(httpvs. https); 等等