On the face of it, this sounds like a no-brainer – yes, of course you can add soil/dirt to a compost heap.
But there are a few things to consider:
Firstly, don’t add too much soil in one go as it can reduce airflow, which is necessary for a healthy compost heap. Earth, especially heavy clay soils, can become pretty compacted into a smothering layer and it can also get into the little gaps around your other stuff. It definitely helps to mix it in at the offset and to turn the heap regularly.
Secondly, if the soil has come from plant pots or flower beds, be aware that it might be carrying viruses or other nasties that attack particular types of plants. Many experienced gardeners, especially those growing veg, practise crop rotation to avoid diseases or parasites getting bedded in – but problematic soil added to a compost heap could undo all that hard work.
Lastly, don’t forget that whatever is in that soil will go into your compost. Twigs and bits of plant matter will rot down but if the soil is rocky or contaminated with other things such as bits of rubbish (or things on the don’t compost list, like animal poop), that’ll end up in your beautiful compost too. It might be easier to get rid of clutter first – possibly by using a garden sieve if you have one – before it’s mixed in with your compost, which might include desirable larger pieces of organic matter.