Minecraft wiki entry for Door-based_iron_golem_farming, associated text: 8. Place doors against the back of the indents. This is to make the villagers think these are homes.
Note: To place doors against the inside wall as shown, stand inside the indent, face the spawning area, look down and "place" the door on the block directly under your feet (works on PC up to at least 1.12.2). Don't place them sideways; this can cause them to be not counted as homes.
It should look like this:

Note: every single door opens onto a blank wall. The villagers should not be going in and out of the doors; they are trapped inside their cups and can't leave.