This proposal is designed with maximum flexibility. The only thing recommended to book in advance is hostels, but you can choose ones with cancellation flexiblity. It's also designed so you generally always spend at least 2 nights in the same place.
Day 1: Arrive in Marrakesh. Stay in a Riad (traditional Moroccan house with courtyard) Riad hostel example, example.
Days 2-3: Explore Marrakesh. Visit Souks (bazaar), Medina (old town)
Day 4-6: Desert excursion. Best to book a guided tour to Merzouga (could book through your hostel and go with folks you meet). You will probably ride a camel, stay in a desert camp, stargaze, sandboarding, etc. Note that it's a long but scenic drive to the desert. You will also drive through the Atlas mountains. Tour example
Day 7: Marrakesh
Day 8: Train to Fes (~7 hrs). Stay in a Riad. Example.
Day 9: Explore Fes
Day 10: Train or bus to Chefchaouen, the blue city. Stay in a hostel.
Day 11: Explore Chefchaouen
Day 11: Return to Fes
Note, you need a visa before you travel here. Unknown how long it will take to get one.
Day 1: Arrive in Accra. Stay in a hostel. Example
Day 2: Explore Accra, see: Jamestown District, Center for National Culture
Day 3: Day trip to Cape Coast, World Heritage Site, and Elmina forts. Hugely significant in the slave trade.
Day 4: Accra
At this point you're getting very far off the beaten path
Day 5: Fly from Accra to Tamale.