rek*_*ire 5 seo drupal breadcrumbs microdata schema.org
我目前对微数据和schema.org有点困惑.microodata和schema.org是一样的吗?我阅读了谷歌和微软的文档,但这并没有帮助我区分这两个名字.
到目前为止,我明白我已经制作了这个HTML代码:
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/" itemprop="url"><span itemprop="title">My Page</span></a>
</span>
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/cat1" itemprop="url"><span itemprop="title">Category 1</span></a>
</span>
<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="/cat1/content" itemprop="url"><span itemprop="title">Content</span></a>
</span>
Run Code Online (Sandbox Code Playgroud)
在我看来,太多的开销,但如果搜索结果看起来不错,那就没关系.是否可以减少html代码的数量?
此外,如果我不需要,搜索引擎如何检测两个不同的路径?
我的下一个问题是我想将这种格式应用于drupal breadcrumps.我在网上找到了这个修复程序,我试图将其包含在我自己的SEO模块中,如下所示:
function mymod_page_alter(&$variables) {
if (!isset($variables['breadcrumb'])) {
$variables['breadcrumb'] = theme('my_microdata', array('breadcrumb' => drupal_get_breadcrumb()));
}
}
function mymod_theme($existing, $type, $theme, $path) {
return array(
'my_microdata' => array(
'variables' => array('breadcrumb' =>array()),
),
);
}
function mymod_menu_breadcrumb_alter(&$active_trail, $item){
foreach($active_trail as $id=>$active_trail_item){
$active_trail[$id]['localized_options']['attributes']['itemprop'][]="url";
}
}
function theme_my_microdata($variables){
$breadcrumb=$variables['breadcrumb'];
print_r(debug_backtrace());
$output="*+*+*+*+*";
if (!empty($breadcrumb)) {
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<div class="breadcrumb">';
$separator="";
foreach($breadcrumb as $breadcrumb_item){
$output.='<span typeof="datav:Breadcrumb">'.$separator.$breadcrumb_item."</span>";
$separator="»";
}
$output .='</div>';
}
return $output."xXxXxXx";
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我检查了所有这些代码是否已执行.但是这个主题并没有应用在我的页面上.为什么那段代码不起作用?这可能与模块有关breadcrumb吗?我知道这个输出将是垃圾,但我看不到结果.
如果我猜对了,而不是由theme.inc行1682ff theme_breadcrumb(...)而不是我的代码创建的输出.
如果有人能帮助我,那也很好,如果你不知道我的问题的所有答案!
sup*_*ero 10
microodata和schema.org是一样的吗?
不,他们不是!
Microdata是WHATWG html规范.这样可以使计算机更容易阅读文档内容.
Schema.org是一个用于描述项目的词汇表.Schema.org由Bing,Google和Yahoo推出.
http://en.wikipedia.org/wiki/Microdata_(HTML)
http://www.w3.org/TR/html5/microdata.html
是否可以减少html代码的数量?
请查看schema.org上的示例代码,以获取WebPage项的标记:http://schema.org/WebPage
Run Code Online (Sandbox Code Playgroud)<body itemscope itemtype="http://schema.org/WebPage"> ... <div itemprop="breadcrumb"> <a href="category/books.html">Books</a> > <a href="category/books-literature.html">Literature & Fiction</a> > <a href="category/books-classics">Classics</a> </div>
搜索引擎如何检测两条不同的路径
如果您使用schema.org中的上述示例,则标记路径而不是单个链接.如果你标记两条路径,它们将被识别为两个单独的路径.(或至少应该)
为什么那段代码不起作用?
我认为这个问题应该与这篇文章分开,并在另一个问题中提出.我不熟悉drupal,一些能回答有关微数据问题的人甚至都不懂PHP.
| 归档时间: |
|
| 查看次数: |
6521 次 |
| 最近记录: |