Robert Louis Stevenson never saw it illuminated by a canopy of fireworks or thrilled at the laser shows which spill out periodically from its ramparts – this photograph, shot by Ryan Buchanan from a Tattoo-less Esplanade, shows August’s My Light Shines On display – but even in his own gas-lit era the author found Edinburgh Castle to be worthy of his wit, his wonder and, of course, his words.

The storied building “overtops the whole city and keeps an open view to sea and land,” he wrote in Picturesque Notes, a love letter of sorts to his hometown. “It dominates for miles on every side; and people on the decks of ships or ploughing in quiet country places over in Fife, can see the banner on the castle battlements.”

Whose banner holds sway over the castle has varied over the centuries. Had you dropped in for a visit in the 7th century it might have been whatever Oswald of Northumbria used for an emblem. Fast forward a few hundred years to the time of David I (who built St Margaret’s Chapel) and into the eras of Alexander II and III and you would find various iterations of the Lion Rampant. Today it’s mostly the Union Jack, though even it’s replaced from time to time: by a rainbow flag, for instance, to celebrate LGBT history month in February.

For centuries, then, the castle has been held, taken, besieged and re-taken, though these days it’s armies of a different sort that tend to muster around the battlements and fortified walls. Still technically a military base, Edinburgh Castle has nevertheless become one of the jewels in Scotland’s cultural crown and a massive tourist draw. It’s Scotland’s most-visited paid-for attraction, generally clocking up well over two million visitors annually, and a recent survey by online marketplace On Buy found that it was also the most “Instagrammable” castle in the world, just ahead of Prague Castle but well ahead of Windsor Castle and picturesque Neuschwanstein Castle in Germany. And of course there’s the Royal Edinburgh Military Tattoo, which has been held annually in a specially-constructed arena on the castle Esplanade since 1950 and which ends with the skirl of the pipes as a lone piper plays on the ramparts, picked out by a spotlight.

What to read

Still with Stevenson, in the closing passages of Kidnapped he leaves David Balfour and Alan Breck Stewart staring wistfully at Edinburgh Castle from their perch at Rest-And-Be-Thankful on Corstorphine Hill a few miles to the west. You can still visit the spot and there is a fine view of the castle. But if it’s chapter and verse you want, check out Edinburgh Castle: The Official Souvenir Guide by Chris J Tabraham.