Adding recipe structured data manually

Adding recipe structured data to your site is one of the best ways to increase the chance of someone clicking on your listing in the search results. The reason for this is that Google (and others) give special treatment to pages with structured data. For instance if you go to google and search for “Post workout recipes” you’ll see at the top of the page the layout for the recipe structured data listings.

Recipe structured data listing on Google

How to add recipe structured data?

There are many different ways to add structured data to your pages but we will use the JSON-LD format. We choose JSON-LD as it’s Google’s preferred format.

Let’s get started:

  1. The first things we need to do is head over to the Scheme Generator from Merkle
  2. Click on “Which Schema.org markup would you like to create?” and choose “Recipe” from the dropdown
  3. From here fill in all the details that you have available. The only required fields are the name and image fields but add as many fields as you can. If you get stuck, check out the example recipe JSON-LD from Google to see what some of the filled in fields should contain
  4. Once you have filled in all the details click on the Google icon near the top of the page. From the dropdown click on “Rich Results Test”. You will be taken to the official Google structured data testing tool.
  5. If Google says everything is all good, go back to the structured data generator and click on the copy icon.
  6. Go to your cms page and paste in the copied text into the html of your page. Make sure you are on html view before pasting the code.

Creating a (very) basic Magento 2 module

In this tutorial we will learn the fundamental aspect of being a Magento 2 developer, namely customising Magento 2 with your own modules. This is a basic module that will get you started on the road to bigger and better things!

What files does a Magento 2 module need?

The following are the minimum files required by a Magento 2 module

  1. registration.php file
  2. etc/module.xml file
  3. composer.json file (This is only required if your code will be managed by composer)

Creating our basic module

Lets first create a folder in ROOT_MAGENTO_FOLDER/app/code using the name “Novxweb”. Inside this folder create another folder called “Helloworld”.

All modules need a namespace and module name. In this case our namespace will be “Novxweb” and our module name will be “Helloworld”.

Creating our registration.php file

In Novxweb/Helloworld create a file called registration.php and paste in the following code:

<?php 
	\Magento\Framework\Component\ComponentRegistrar::register(
		\Magento\Framework\Component\ComponentRegistrar::MODULE, 'Novxweb_Helloworld',
		__DIR__
);

Creating our module.xml file

In Novxweb/Helloworld/etc create a file called module.xml and paste in the following code

<?xml version="1.0"?>
	<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
		<module name="Novxweb_Helloworld" setup_version="0.0.1">
		</module>
	</config>

Installing the module

Using ssh change directory to the root of the Magento installation and then issue the command

bin/magento setup:upgrade

In the output you should see your module “Novxweb_Helloworld”. That’s it! you have created a Magento 2 module.

This was a very a basic module that we will need to build on to make it do something useful.