The Canadian city of Nanaimo, in British Columbia, has been a scrappy outpost of the Hudson’s Bay Company, a coal mining center and a timber town. But its place in history may be forever entwined with its culinary namesake, one of the world’s sweetest treats.

The Nanaimo bar (pronounced nuh-NYE-mo) is a three-layer no-bake square that for the last seven decades or so has been a steadfast source of comfort to Canadians at weddings and funerals, birthdays and bar mitzvahs. Across the country, you’ll find the sugary bars for sale at small-town gas stations and supermarkets, where they compete with Nanaimo bar baking kits. The Tim Hortons restaurant chain even created a filled doughnut with the flavors of the Nanaimo bar for the nation’s sesquicentennial in 2017, a nod to its status.

Even its name is proudly Canadian.

“I like to call it the Kardashian of Canadian desserts because really, if it had been named anything else, I don’t think it would have lasted,” said Lenore Newman, the author of “Speaking in Cod Tongues: A Canadian Culinary Journey.” “But it’s the Nanaimo bar, so of course people make it.”

The square looks something like a geological cross section. Its base is sedimentary: coconut and chopped walnuts bound together by a buttery silt of cocoa and crushed graham crackers. A middle layer of yellow buttercream teeters on the brink of liquefaction. And its top crust of chocolate, hard and brittle, thaws like the Arctic tundra the longer it lingers at room temperature.


Each layer is spread in a baking pan.CreditAlana Paterson for The New York Times

“It’s that balance of sweetness and texture that makes it just so appealing, and it looks pretty,” said Anna Olson, a pastry chef and the host of the Food Network Canada show “Bake With Anna Olson.” “For the home cook, it’s an attractive dessert: It doesn’t look sloppy, it doesn’t look crafty.”

The Nanaimo bar’s story begins with the so-called dainty recipes of the mid-20th century, treats engineered to be whipped up for unexpected company from pantry staples.

“The base layer was one of these 1950s recipes that circulated among housewives in mill towns all around the British Empire,” said Dr. Newman, a geography professor at the University of the Fraser Valley, in British Columbia, who also noted that a New Zealand dessert, the caramel slice, has a similar base.

Dr. Newman believes that the women of Nanaimo added the middle and top layers. The first mention that she and a student, Shea Wind, could find was in a 1953 recipe in The Vancouver Sun for London smog bars, which stated that they were also called Nanaimo bars.

The use of custard powder — an instant custard mix, which was a pantry staple of the empire, devised for those with egg allergies — gave their new dainty its distinctive yellow belt.

Around the same time, bakers in Canada’s prairie provinces were serving up a similar creation, also called the smog bar, which Jean Paré, 91, learned how to make from her mother, Ruby Elford, in Irma, Alberta, a town of 250 about 110 miles southeast of Edmonton.

“I forget how many do’s I went to before I finally found that they were called Nanaimo bars by other people,” she said in a phone interview, using an old-fashioned term for a gathering.

Mrs. Paré (pronounced Perry) is a well-known Canadian cookbook author whose “Company’s Coming” books have sold by the millions. She included Nanaimo bars in her first book in the series, “150 Delicious Squares,” in 1981.

Before she wrote cookbooks, Mrs. Paré catered events. Nanaimo bars were almost always on the dessert-square tray, which would make an appearance anytime a sweet snack was required, often at the “midnight lunch” served after the dinner and dancing at Albertan wedding receptions. “I didn’t have to bake them, and they froze so well,” she said.

Only once, she said, did she decide to sub out the Nanaimo bar, and people asked for them by name: “So that was the last time I ever tried that.”

Before Susan Mendelson began her catering company, the Lazy Gourmet, she sold Nanaimo bars at a theater in Vancouver, B.C.CreditAlana Paterson for The New York Times Ms. Mendelson’s Nanaimo bars turn up at “womb-to-tomb events,” like baby showers, bar and bat mitzvahs, weddings and funerals.CreditAlana Paterson for The New York Times

Susan Mendelson was a university student in Vancouver in the 1970s when she started making the bars and selling them at a local theater, using a recipe from a classmate. They were a hit, and she opened a catering company, the Lazy Gourmet, with a friend.

She published the basic recipe in her first cookbook, “Mama Never Cooked Like This,” and variations in subsequent ones, including the official cookbook of the 1986 world’s fair in Vancouver, which Dr. Newman credits with helping to spread the bar’s fame. Ms. Mendelson’s version of the bar was so good that the novelist Margaret Atwood included it in her “Canlit Foodbook,” which compiled writing and recipes from Canadian authors.

And the city of Nanaimo finally took notice of its well-traveled square. A mascot, Nanaimo Barney, turned up at public functions, and a contest was held in the 1980s to find the ultimate Nanaimo bar recipe.

Nanaimo bars are often cut into small pieces, because they are so sweet. The bars Ms. Mendelson sells through her company, the Lazy Gourmet, are cut into relatively large, 2 1/2-inch squares.CreditAlana Paterson for The New York Times The bar’s buttercream layer takes well to different flavors. The classic bar, left, is made with custard powder. Ms. Mendelson’s cappuccino bar, right, is flavored with cocoa and coffee in addition to the custard powder, and has a milk chocolate topping.CreditAlana Paterson for The New York Times

Joyce Hardcastle, a widow with two children, pulled a recipe, provenance unknown, from her recipe box and decided to enter Nanaimo’s contest. Allergic to walnuts, she swapped in almonds. And she made the bars with European-style unsalted butter, rather than the salted butter that was often used.

“I really think that the city didn’t want peanut butter in them, or mint or liqueur,” Ms. Hardcastle said. “I think they just wanted something basic, and that’s what I did — the really basic Nanaimo bars — and that’s what won, to my surprise.”

She has since sold tea towels and aprons printed with her recipe, and has made so many bars that she can tilt her baking pan so the molten chocolate forms a topping as smooth as freshly Zambonied ice.

Joyce Hardcastle won the city of Nanaimo’s recipe contest in the 1980s. She substituted almonds for the traditional walnuts in the base layer, and used unsalted butter.CreditAlana Paterson for The New York Times

Nanaimo, for its part, has designated local restaurants and cafes where people can try the bars, in the spirit of the food-tourism trails that two regions in Ontario have created for that other signature Canadian dessert: the butter tart.

Despite all the variations on the Nanaimo bar — versions exist made with peanut butter, mocha and cranberry — there are still rules to be followed, said Ms. Olson, the pastry chef.

“You’re allowed to change it and alter it, but you still have to respect the crust, filling, chocolate topping,” she said. “You can still call it a Nanaimo bar by changing up the flavors.”

The buttercream takes well to flavorings, and you can experiment with the nuts in the base layer. (Though Ms. Atwood, a purist, prefers walnuts.) If you do change up the nuts, you want a tender choice, like almonds or pecans. “A hazelnut might show its texture and be too crunchy,” Ms. Olson said.

Canadian bakers point to Bird’s Custard Powder as a key ingredient in a true Nanaimo bar.CreditAlana Paterson for The New York Times

Custard powder may be one reason the Nanaimo bar hasn’t spread farther south. While it is available online and at some specialty stores in the United States, it remains a relatively obscure ingredient to Americans. Some recipes say instant vanilla pudding can be used as a substitute, but that makes the buttercream clumpy, and the finished bar lacks that essential yellow hue.

“I have a container of Bird’s Custard Powder that sits in my pantry because its only function is for Nanaimo bars,” Ms. Olson said. “I wouldn’t use it for anything else. I make my own custard for any other situation.”

Recipe: Nanaimo Bars

More Canadian treats
Nanaimo Bars

Butter Tarts, Canada’s Humble Favorite, Have Much to Love

Butter Tarts

Butter Tart Squares