Once upon a time, I was reading an essay on Conan the Barbarian. You may, or may not, know that in the original tales, as written by Robert E. Howard, Conan included being a pirate among his other adventures. Howard even put the pirate strongholds on his map.
They were nowhere near the trade routes.
This, of course, would not and could not work. True, the vast superiority of sea-travel to going by land in days of old made piracy more feasible than banditry. There were actual pirate kingdoms the way there could not be bandit kingdoms, because pirates could fare farther in search of prey. But that reflects that not that sea-travel was easy, simple, and convenient, but that land-travel was nightmarishly difficult. Sea travel did not depend on muscle power but it did on wind and current. Becalming was a grave danger, all the more in that provisions and drinking water were hard to keep in sufficient quantities.
Thus, there have been pirate havens such as Port Royal and Madagascar, but these have been close enough to trade routes for the pirates to find the merchants. Yes, this does make it easier for the navies to find them, but there is no escaping it. The great rule was "no prey, no pay" -- and more important, until you found merchant ships to prey on, there was no finding of rations, rope, sails, and all the material needed to keep the ship going. Gold and other treasure would also work as long as you had the port to buy this material and keep your ship sailing. Any excess could be put to the second part of the slogan of "A short life and a merry one," because there was no point in saving up your treasure in such a life -- let alone burying with a secret map.
And because finding holes in other people's world-building and deciding to make them work is, actually, a nice source of inspiration, I decided to take on the notion. Not burying the treasure. In fact, in the era of Caribbean piracy, two pirates did bury treasure. Sir Francis Drake buried the silver because the loot was more than he could carry off, and he hoped to return for it. Since he did not move it far, this did not work. Captain Kidd wanted to use the treasure as a negotiating point with the authorities, which meant he had to hide it from them. That did not work either. Pirates who bury treasure can be justified.
But the sea routes, that was a little more challenging.
Conan's problem was, however, that no one used magic. True, the tales glided over such little matters as unfavorable winds and becoming becalmed, reefs, navigation especially without reliable clocks, scurvy, and all the other adventures of pre-steam sea-faring. (You get that a lot not only in fantasy but in historical settings. Amazing how often you skip the dull parts.)
In my tale, I did do a little of that. All ships use wizards for their winds, and so all ships are still sailing ships, but far more reliable than those dependent on the wind.
However, my big change was that the pirate stronghold was nowhere near the merchant ships, or the cities they would also raid, thus making it all but impossible for navies to find, or assault. At least, that was the idea. I did set the port at least far enough away to make sailing there a challenge, enough that it would be a serious cost to simply sail from there as pirates. How did the pirates get out to raid, and back with loot? Magic! Like a science fictional warp drive or wormhole, they are borne off to far-off lands.
And since it was magic, it was much easier to put it into the hands of pirates and not the kings with their navies. Indeed, I put it into the hands of one pirate, thus giving him undue influence among his fellows -- historically pirates gave no authority to their captain except in actual battle -- though he did have to share out the loot generously to keep his position. Then, with it, he allowed them not only to plunder ships but entire cities, and poured wealth into their hands for a rich and merry life.
Thus aiding not only the pirates, but myself, since that sets up issues for dealing with them, and lets me give my characters a lot of grief. The king, and his men, grow quite desperate, and thereby hangs my tale.
It's The Witch-Child and the Scarlet Fleet, available at Amazon , Barnes & Noble, Kobo, Apple Books, Everand, Smashwords, and many other fine venues.
On the other hand, Viking pirates buried a lot of treasure as part of their funeral rites.