Preheat the oven to 425°F/210°C.
Wash and dry the sweet potatoes and poke them with a fork. Wrap each one with foil and place them on a baking sheet covered with parchment paper.
Bake for 40 minutes to an hour until tender.
Slice the potatoes in half and use a spoon to scrape out the inner flesh, making sure to leave at least a ¼-inch (6 mm) thick border on each side, saving the scooped-out potato parts to use for side dishes.
Heat the olive oil in a large pan set over medium heat.
Add the onion and cook, stirring occasionally, until softened, 6 to 8 minutes.
Add the garlic and cook, stirring occasionally, until fragrant, 1 to 2 minutes.
Add the spinach, turn the heat to low, cover, and cook, until the spinach is very soft, about 5 minutes. Remove from the heat.