|
| 1 | +# Google SEO Notes for eCommerce |
| 2 | + |
| 3 | +These are loose notes about what I am learning about boosting SEO for an e-commerce site. |
| 4 | + |
| 5 | +- [Google Search Central](https://developers.google.com/search) is where you can go to find info about how to help your site do better in Google rankings. |
| 6 | +- You can add [structured data](https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data) to your html templates to help Google learn more about your site. |
| 7 | +- You can find the schemas for the structured data at [Schema.org](https://schema.org). |
| 8 | +- JSON-LD is [JSON for Linking Data](https://json-ld.org) and is one form of structured data. It is also the one I will be using. |
| 9 | +- You add "snippets" in specific formats that are specifed in the schemas, and this helps Google render your information in more helpful ways, and helps people find your site |
| 10 | + |
| 11 | +## `offers` |
| 12 | + |
| 13 | +- [The `Product` Snippet](https://developers.google.com/search/docs/appearance/structured-data/product-snippet) |
| 14 | +- [`Offer` on Schema.org](https://schema.org/Offer) |
| 15 | + |
| 16 | +Adding data from the [`Product` snippet](https://developers.google.com/search/docs/appearance/structured-data/product-snippet) to your [structured data](https://schema.org) (in my case, [JSON for Linking Data](https://json-ld.org)) helps Google show that you have products for sale. |
| 17 | + |
| 18 | +In practice, this feels similar to setting up a `meta` tag |
| 19 | + |
| 20 | +### Adding `ld+json` with pricing information to a Django template |
| 21 | + |
| 22 | +```html |
| 23 | +<!-- /templates/product_list.html |
| 24 | +
|
| 25 | +{% block extra_head %} |
| 26 | + <script type="application/ld+json"> |
| 27 | + { |
| 28 | + "@context": "https://schema.org/", |
| 29 | + "@type": "ItemList", |
| 30 | + "name": "Products for Sale", |
| 31 | + "itemListElement": [ |
| 32 | + {% for product in products %} |
| 33 | + { |
| 34 | + "@type": "ListItem", |
| 35 | + "position": {{ forloop.counter }}, |
| 36 | + "item": { |
| 37 | + "@type": "Product", |
| 38 | + "name": "{{ product.name }}, |
| 39 | + "url": "{{ request.scheme }}://{{ request.get_host }}{{ product.get_absolute_url }}", |
| 40 | + "offers": { |
| 41 | + "@type": "Offer", |
| 42 | + "price": "{{ product.default_price }}", |
| 43 | + "priceCurrency": "USD" |
| 44 | + } |
| 45 | + } |
| 46 | + }{% if not forloop.last %},{% endif %} |
| 47 | + {% endfor %} |
| 48 | + ] |
| 49 | + } |
| 50 | + </script> |
| 51 | +{% endblock extra_head %} |
| 52 | +
|
| 53 | +``` |
| 54 | +
|
| 55 | +This snippet does the following: |
| 56 | +
|
| 57 | +- Add a `<script>` tag for the `ld+json` structured data about our products for sale to our product-list template |
| 58 | +- Declares our schema in `@type` |
| 59 | +- Loops through our products to set up each `item` attribute |
| 60 | +- Creates an `offers` attribute for each product, where we can add pricing information |
| 61 | +
|
| 62 | +<hr> |
| 63 | +
|
| 64 | +There are a lot of other options for adding product information to templates to improve their search performance. I'm going to look through the specification and do a little reading on how important the different attributes are. |
0 commit comments