It seems perhaps rather ironic that Santiago travels so far only to realise that the treasure he seeks was always so close to his original starting place. However, one of the main themes of the story is the way that a fixation on our Personal Legend for its own sake can actually lead to a loss of that Personal Legend, as is shown through the example of the alchemists, who knew how to convert base metals into gold, but then lost that ability, because they became obsessed with the gold and not the learning and purifying process of pursuing their Personal Legend. Alchemy is a very important motif in this book, as to become gold, metal needs to be purified of its dross, just as Santiago needs to be purified of his own weaknesses and lack of understanding in order to achieve his Personal Legend. Basically, Santiago realises, there is much more at stake than merely the discovery of his treasure, and as he digs up the treasure at the end, he is aware of how much he has learned and changed as a result of his journey:
He thought of the many roads he had travelled, and of the strange way God had chosen to show him his treasure. If he hadn't believed in the significance of recurrent dreams, he would not have met the Gypsy woman, the king, the thief, or...
In other words, although Santiago gains physical treasure at the end of this travels, the true treasure he gains comes from the experiences he has endured and the people he has met on his way, and how they have transformed him into a very different person from the Santiago who is introduced to the reader at the beginning of the novel.