Peel shallots and trim them so they are all the same length. This is vital as it ensures they all cook in the same time.
Add the sugar to a baking tin about 9" in diameter (or a tarte tatin tin if you have one. Heat on the hob until the sugar melts and caramelises (looks nut brown). DO NOT STIR the sugar, just shake the tin to make sure that it all melts evenly.
Carefully add the shallots (caramel can cause very nasty burns).
Strip the leaves from the thyme and add to the shallots.
Roll out the pastry and cut a rough circle just larger than the size of tin you are using. Lay it over the shallots and tuck in around the sides.
Add to a preheated 200 degrees C oven for around 25 minutes or until the pastry looks done.