Ruby on rails, Solidus e-comerce, problem with google indexing

108 views Asked by At

Google indexing stopped on my site with error like

"invalid value type for "name" field. 

The rails code generating this HTML is

<% 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, current_pricing_options, 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), url, 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 %>

The page displays fine but does not index on in google. How can I fix this? do I have a syntax error of so in the rails code? I don't see one. what could be causing this?

1

There are 1 answers

0
Charlie_oscar On BEST ANSWER

I fixed this by rewriting the rails code wrapped in html header tags like below:

 <h6 style="color:Black;" class="info" itemprop="name">
    <%= link_to(truncate(product.name, length: 50), url, title: product.name) %>
  </h6>