You can hook them up almost directly.
When the sun is shining and the panel is capable of 20 W, the power supply on the output of the panel will have no problem holding up the 12 V output with only 5 W drawn from it. When there is no sun, there is no power in. The motor won't run, but nothing bad will happen.
The problem is when there is not quite enough power to make the motor spin. The 12 V supply will collapse, but could still provide some power at whatever voltage it goes down to. The worst case is the motor draws just below the current it needs to start turning. That means all the power into the motor is getting turned into heat. This can overheat the motor.
The solution is a undervoltage lockout. Add a relay that either connects the motor or a 24 Ω or so power resistor to the 12 V supply. The relay connects the resistor load when off, and connects the motor only when specifically energized.
A small circuit turns on the relay only when the supply goes above maybe 11.7 V and turns it off when the supply goes below maybe 11.4 V for a few seconds. This guarantees the motor is only run when there is enough voltage to run it properly. The time delay is intended to get past the motor's startup, when it takes more current than during normal operation. A large capacitor on the 12 V supply or the solar panel will also help.
The purpose of the load resistor when the motor is not connected is to test what the supply can deliver with a little more load than the motor requires. If you didn't do that, even a little sun could cause the supply to go to 12 V. However, as soon as the motor is connected, the supply would collapse. The system would constantly oscillate, which would be bad for the motor and the relay.
A 24 Ω resistor dissipates 6 W with 12 V applied. That means if the supply is producing 12 V with the resistor connected, it is capable of sourcing at least 6 W. The minimum amount of power available at 12 V together with a large cap on the supply and/or solar panel will need to be tweaked to get past the large startup current the motor will draw when first switched on. Note that this needs to be a power resistor, probably 10 W for the 24 Ω used in this example.