After a long, uphill cycle to the Danish battlefield of Dybbøl, I stopped to gaze at the brilliant-white windmill with its black-capped roof and great red sails, sitting high in the clouds above the fishing town of Sønderborg. I was cycling from the German border to Copenhagen across Denmark's islands – but had been side-tracked by the curious story of southern Jutland's rebel cakes.

Dybbøl Windmill had ground wheat into flour across the centuries from 1774, despite being pummelled in two Schleswig wars and destroyed more than once by fire. After the Prussian-Austrian occupation of southern Jutland in 1864, the mill was, if anything, busier than ever. When the occupiers refused to give the Danes an alcohol license for their community halls, the defiant Jutlanders thought that if they couldn’t have their beloved coffee punch with schnapps, they’d have cake instead – made with flour from the mill, of course.

You may also be interested in:
• The cakes beloved by anarchists
• The unlikely sausage that saved lives
• A secret island obsessed with food

The community hall was an important part of Danish culture; a place to meet and share ideas. During the occupation, the need for the Jutland Danes to preserve their national identity became even more important. The hall became a Danish micro-society, a safe haven, where the southern Jutlanders could sing patriotic Danish songs and celebrate their Danish-ness. The kaffebord, or coffee table, was not so much about coffee (now that the Danes couldn't make coffee punch) but about the Danish cakes that stretched along the long table.

With every year that passed under the occupation, the spreads became more elaborate, as Jutland's cake-making housewives jostled to be queen of the kaffebord. Cream cakes, pastries, fruit tarts and biscuits of every sort crammed the table. It was full-on competition, but more importantly, it was an act of defiance and resistance against the oppressor. After a referendum in 1920, southern Jutland was handed back to the Danes, and although the liquor license was granted again, the coffee table, too good to abandon, continued to thrive. To this day, it's a favourite way to celebrate birthdays, anniversaries and other special events in the region.

It was an act of defiance and resistance against the oppressor

Dybbøl Windmill didn't just produce flour for the coffee-table cakes, however; the patriotic miller allowed Danish soldiers to use it as an observation post during the second Schleswig war of 1864. Signals were transmitted to the men on the watch, but despite the army's best efforts, they were unable to hold their line of defence at Dybbøl against the better equipped Prussian-Austrian army. The Danish were overwhelmed and south Jutland was captured.

The visitor centre attached to the windmill tells this story, while across the road, on the site of the Dybbøl Battlefield, a memorial pays homage to the fallen Danish soldiers. Below it, the land drops away to the Strait of Alssund and the fishing town of Sønderborg just out of sight, where I was heading in search of the Jutland coffee table and its mountain of cake.

I swung my leg over my bicycle and free-wheeled through fields of bright rapeseed down to the strait. Across the water, the red roofs and colourful facades of the harbour houses stretched out along the quayside to a heavily fortified castle. Now a museum, Sønderborg Castle tells the story of Prussian-Austrian occupation of southern Jutland after the 1864 Schleswig War, and again of German occupation in World War II. I wanted to find out more.

Ignoring the attractive waterfront with its terraced cafes and castle for the moment, I crossed the drawbridge and pushed on up the hill to a pedestrianised shopping street in the heart of the town. The restaurant, Det Sønderjyske Køkken (The South Jutland Cuisine), was hosting a coffee-table event – and I was about to eat my own weight in cake and biscuits, or so it seemed. Inside, the room was filled with locals and a handful of Dutch and Germans, along with my holidaying British companions. At the head of the room, a long table was stacked high with meringues, puddings, cakes, pastries and biscuits. Working along the table from left to right, I piled my plate high, glad that most of the portions were small or bite-sized.

“The number of cakes on the table has varied through the years,” Jesper, the restaurant owner explained to me. “But somehow we seem to have settled on seven. Nowadays, tradition decrees there should be seven soft cakes and seven hard cakes – and sometimes, when there's a really extravagant kaffebord, there will be seven layered cream cakes as well.”

“So, where do I start?” I asked.

“We start with pomle – the bread roll with butter,” he answered.

I ate the cardamom-flavoured roll with jam before going on to try the Sønderjysk festkringle, a buttery Danish pastry made with candied citrus peel and raisins.

“Now we eat the two ‘stop cakes’,” said Jesper. “‘Stop’ meaning have a rest with the lighter cakes before returning to the richer soft cakes. Honningkage is honeyed gingerbread topped with apricot compote – and krydderkage is a plain spicy cake.”

“It must have been very expensive to lay on so many elaborate cakes during the Prussian occupation, was it not?” I asked.

“That's true. The most elaborate coffee tables were held in rural areas where country folks had the ingredients on their farms,” he said.

Returning to the richer soft cakes, I tried the rabarber trifli, a delicious rhubarb trifle, then the blommetærte, a plum tart, before finishing with the brø'tort, a nutty rye cake with a blackcurrant topping. There was no question; I was on a sugar rush.

But just as partakers think they have reached a saturation point with these rich and filling ‘soft cakes’, the thoughtful Jutland cake-makers calm the palate – and the stomach – with seven plainer and lighter ‘hard cakes’, or biscuits.

First up was the knepkager, its delightful name describing the crunch the biscuit makes when you bite into it, then the fedtkager, a biscuit made with lard. Next, I tried the almond nøddetvebakker, baked twice (once to harden the biscuit, and again to give it its warm brown colour). After that came the herrnhutkager, a syrupy, spicy bake with orange and lemon zest, cloves and pepper.

My cake marathon had almost come to an end: I feasted on vaniljekrans (a vanilla ring cake) and the wonderfully named goderåd, which translates as ‘good advice’. Last of all, I bit into the ingenting, a meringue drizzled with rum. The meringue name demonstrates the Danes mischievous sense of fun: when guests had munched their way through six hard cakes, they would be asked what they could still eat. ‘Nothing,’ they would usually reply, and would promptly be offered ingenting, which means ‘nothing’.

A huge variety of cakes and biscuits can be found at coffee tables across southern Jutland, some with strange and amusing names: søsterkage (sister cake), and kys og klap (kisses and applause), for example. But the most intriguing of all are the fried biscuits called klejner, or ‘twisted boys and girls’. The boys are cut into rectangular shapes, with one end of the pastry pulled through the hole in the middle to make clear the boy's gender, while the girls are cut with a round glass and twisted into a feminine shape, with a hole made with a thimble.

I staggered out of Det Sønderjyske Køkken, my stomach filled with spice and sugar and fruit and nuts. I thought about the Danish gathered in their community halls, defiantly holding meetings, singing patriotic Danish songs and eating cake in spite of their Prussian oppressors, only to experience German occupation all over again in World War II. “What must that have been like?” I wondered.

I spent the night in a country cottage overlooking the Baltic Sea just a few miles through the woods on the other side of the harbour. Outside, the wind rustled in the great copper beech, a red tree once planted next to many dwellings across southern Jutland to mark the home of Danish patriots, who also painted their doors red to demonstrate their alliance to the Danish flag.

In the morning, I had a visit from the 78-year-old former mayor of Sønderborg, Mr Hansen. Nobody seems to know his Christian name, and he is simply referred to as AP. He had come by to tell me about life under the second German occupation. Born at the beginning of World War II, his early childhood was marred by war and the new German occupation. We sat down under the window, surrounded by sofa throws and candles, the blue of the Baltic Sea sparkling in the sunlight beyond the barley field. It was hard to imagine those turbulent times in this peaceful place.

“How did the Jutland Danes feel about being occupied all over again in the Second World War?” I asked.

“You know, it was very peaceful to begin with,” he said. “The Germans didn't try to suppress our Danish culture. We were allowed to get on with our lives as usual, so there was little resistance initially. The resistance came later in 1943 when Hitler called for the deportation of Danish Jews. When the Danish Resistance organised a strike, the German occupiers became more heavy-handed. Nonetheless, even in the early days, it was still a shock to be occupied all over again. The Germans arrived in the springtime. The air was different and there was the constant drone of planes. Whenever I hear the sound of planes in spring, it’s still emotional for me.”

It was a shock to be occupied all over again

Mr Hansen ran his fingers over a stock of white hair, lost in memories of the war. “My parents were good people,” he said. “They took in a Jewish boy, Hans Franz, and eventually helped him to get to Sweden. Later, my mother sheltered a Danish woman who'd had a child to a German soldier. My parents weren’t the only decent Danes: many other ordinary Danes helped to evacuate more than 7,000 Jews to Sweden.”

“And how do people feel about the Germans now after two occupations?” I asked.

“There is still a German minority group living here, and they are encouraged to preserve their own culture,” he replied. “They have their own schools, libraries and sports clubs. We have a good relationship with our German neighbours too. There are many German tourists who come back faithfully year after year to spend their holidays here. They love Denmark and its culture.”

I thought of the German visitors who had mingled with the Danes at the kaffebord at Det Sønderjyske Køkken the day before. The coffee table, once associated with war and rebellion, had become an opportunity for shared friendship and cake.

It's always been a very personal experience

When chatting to Gerda Bouma from the local tourism office, she mused: “You know, the coffee table has been southern Jutland's best-kept secret. It's always been a very personal experience for the local people who have held it in their own homes on special occasions with close family and friends over the decades. But it's time to share the coffee table experience with others, don't you think?"

I couldn't have agreed more as I cycled away from Sønderborg with a belly full of cake.

Join more than three million BBC Travel fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital and Travel, delivered to your inbox every Friday.