如何解决Ruby on rails、Solidus 电子商务、谷歌索引问题
Google 索引在我的网站上停止并出现类似错误
"invalid value type for "name" field.
<% if products.any? %>
<ul id="products" class="inline product-listing" data-hook>
<% products.each do |product| %>
<% url = spree.product_path(product,taxon_id: @taxon.try(:id)) %>
<li id="product_<%= product.id %>" class="columns three <%= cycle("alpha","secondary","","omega secondary",name: "classes") %>" data-hook="products_list_item" itemscope it
emtype="http://schema.org/Product">
<% cache(@taxon.present? ? [I18n.locale,current_pricing_options,@taxon,product] : [I18n.locale,product]) do %>
<div class="product-image">
<%= link_to(render('spree/shared/image',image: product.gallery.images.first,size: :small,itemprop: "image"),url,itemprop: 'url') %>
</div>
<%= link_to(truncate(product.name,length: 50),class: 'info',itemprop: "name",title: product.name) %>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<% if price = product.price_for(current_pricing_options) %>
<span class="price selling" itemprop="price" content="<%= price.to_d %>">
<%= price.to_html %>
</span>
<% end %>
<span itemprop="priceCurrency" content="<%= current_pricing_options.currency %>"></span>
</span>
<% end %>
</li>
<% end %>
页面显示正常,但未在 google 中建立索引。我怎样才能解决这个问题?我在 rails 代码中有这样的语法错误吗?我一个都没看到。什么可能导致这种情况?
解决方法
我通过重写包含在 html 标头标签中的 rails 代码解决了这个问题,如下所示:
<h6 style="color:Black;" class="info" itemprop="name">
<%= link_to(truncate(product.name,length: 50),url,title: product.name) %>
</h6>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。