Summary: Codfish pie is an easy, comforting, and perfect recipe for the whole family. Layers of cooked potato, shredded cod, and creamy béchamel are baked in the oven until a golden and irresistible surface forms. It's ideal for using up leftover cod, can be prepared in advance, and is always a crowd-pleaser. In this recipe, we show you the step-by-step assembly, with tips for a perfect béchamel and variations to customize your pie.
Table of Contents
What is codfish pie
Codfish pie is a baked dish that combines layers of shredded cod, cooked potato, and béchamel sauce, gratinéed until it has a golden, crispy surface. It is, in essence, a seafood version of lasagna or shepherd's pie: layers of flavorful ingredients held together by a creamy sauce and topped with an irresistible gratin.
This dish has roots in popular Spanish and Portuguese cuisine, where cod is an absolute staple during Lent and the winter months. In Portugal, empadão de bacalhau is a Sunday classic; in Spain, codfish pie appears in family cookbooks throughout the Cantabrian coast, Galicia, and Catalonia, each region with its own variations.
What makes this dish special is its versatility and practicality. It's perfect for using up leftover desalted cod, can be assembled the night before and baked the next day, feeds many diners with economical ingredients, and is loved by adults and children alike. It's elevated leftover cooking made into a main course.
At Mercat del Ninot in Barcelona, where we've been working with Icelandic cod since 1990, codfish pie is one of the recipes we most recommend to our customers. It's the perfect entry point for those who want to cook with dried cod but are looking for something simple, without the technical complications of a pil pil or a brandade.
Ingredients for codfish pie
For 6-8 people (25x35 cm dish)
- 500 g dried shredded cod (desalted) or leftover cooked cod
- 1 kg medium potatoes for boiling
- 1 large onion, finely chopped
- 2 cloves garlic, minced
- 1 red pepper (optional, in thin strips)
- 3 tablespoons extra virgin olive oil
- Fresh parsley, chopped
For the béchamel sauce
- 80 g butter
- 80 g wheat flour
- 800 ml whole milk (at room temperature)
- Salt, white pepper, and nutmeg
For the gratin
- 100 g grated cheese (Emmental and Parmesan blend)
- 2 tablespoons breadcrumbs
- A knob of butter for the dish
Notes on ingredients
Cod: Dried shredded cod is the most practical option for this recipe. It comes in small flakes, desalt's faster than whole pieces (12-24 hours), and integrates perfectly between the pie layers. If you have leftover cooked cod (from a pil pil, brandade, or baked cod), you can also use it — simply shred it with your hands.
Potatoes: Use firm-fleshed potatoes (like Monalisa or Kennebec) that won't fall apart when cooked. Floury potatoes (like Agria) break down too much, and the pie will be mushy instead of having defined layers.
Béchamel: The 80-80-800 ratio (butter, flour, milk) yields a medium-consistency béchamel, ideal for a pie. If you prefer it thicker (so the layers hold better), increase to 100-100-800. Always use milk at room temperature to avoid lumps.
Related Cod Products
How to make the perfect béchamel sauce
Béchamel sauce is the soul of codfish pie. A well-made béchamel — creamy, lump-free, well-seasoned — elevates the entire dish. A poorly made béchamel sinks it. Here are the steps for a foolproof béchamel:
Step 1: The roux
Melt the butter in a large saucepan over medium heat. When it's completely melted and starts to foam (but without browning), add the flour all at once. Stir constantly with a whisk or wooden spoon for 2-3 minutes. The mixture (the roux) should be homogeneous and start to smell like cookies. This step is crucial: if you don't cook the flour enough, the béchamel will have a raw taste; if you cook it too long, it will brown and change color.
Step 2: Add the milk
Remove the saucepan from the heat. Add the milk in three or four batches, stirring vigorously with the whisk after each addition. At first, the mixture will be very thick and seem like it won't incorporate — this is normal. Keep stirring. With each batch of milk, it will loosen up until you achieve a homogeneous cream.
The trick to avoiding lumps is: milk at room temperature, add it gradually, and always stir in the same direction.
Step 3: Cook and season
Return the saucepan to medium-low heat. Cook the béchamel, stirring constantly for 8-10 minutes, until it thickens enough to coat the back of a spoon (if you run your finger across the spoon, the mark should remain). Season with salt (a little, as the cod adds salt), freshly ground white pepper, and grated nutmeg. Nutmeg is essential — it transforms a bland béchamel into something special.
Remove from heat. If you're not using it immediately, cover the surface with plastic wrap directly touching the béchamel to prevent a skin from forming.
Step-by-step recipe
Step 1: Desalting the cod (12-24 hours beforehand)
Place the shredded cod in a large bowl covered with cold water. Place it in the refrigerator for 12-24 hours, changing the water 2-3 times. Shredded cod desalt's faster than whole pieces because it has more surface area exposed to the water.
Taste a small piece before draining: it should be slightly salty, not bland or excessively salty. Drain well and gently squeeze with your hands to remove excess water. Set aside.
Step 2: Cooking the potatoes
Wash the potatoes and boil them whole, with skin, in salted water for 25-30 minutes, until a knife pierces them easily but without falling apart. Do not overcook them — they should remain firm for slicing.
Drain, let cool for about 10 minutes, and peel them. Slice them about 5 mm thick. Set aside.
Step 3: Preparing the cod sofrito
Heat the olive oil in a large skillet over medium heat. Add the chopped onion and cook for 8-10 minutes, stirring occasionally, until transparent and tender. Add the minced garlic and red pepper strips (if using) and cook for another 3-4 minutes.
Add the desalted shredded cod. Sauté it with the sofrito for 3-4 minutes, mixing well so that it absorbs the flavors. Add the chopped fresh parsley. Taste for salt — remember that the cod already adds salt, so you may not need to add any. Remove from heat and set aside.
Step 4: Preparing the béchamel sauce
Follow the detailed steps in the previous section. Make the béchamel with the 80-80-800 ratio (butter, flour, milk) and season with salt, white pepper, and nutmeg. The béchamel should have a thick cream consistency but still flow — neither too liquid (the pie won't hold) nor too thick (it will be difficult to spread).
Step 5: Assembling the pie in layers
Preheat the oven to 200°C (390°F) with top and bottom heat.
Grease a baking dish (25x35 cm or similar) with butter. The layer assembly is as follows:
- First layer — Potatoes: Cover the bottom of the dish with a layer of potato slices, slightly overlapping like fish scales. Season lightly with salt and pepper.
- Second layer — Béchamel: Pour one-third of the béchamel over the potatoes, spreading it evenly with a spatula or spoon.
- Third layer — Cod: Spread half of the cod sofrito over the béchamel, distributing it evenly.
- Fourth layer — Potatoes: Another layer of potato slices.
- Fifth layer — Béchamel: Another third of béchamel.
- Sixth layer — Cod: The rest of the cod sofrito.
- Seventh layer — Potatoes: The last layer of potatoes, arranged decoratively (overlapping in concentric circles if you want a pretty result).
- Final layer — Béchamel and gratin: Pour the last third of béchamel over the top, covering the entire surface. Sprinkle the grated cheese and breadcrumbs over it.
Step 6: Bake and gratinate
Bake the pie on the middle rack of the oven at 200°C (390°F) for 25-30 minutes, until the surface is golden and bubbly. If you see it browning too quickly on top but the inside isn't hot, lower the temperature to 180°C (350°F) and cover with aluminum foil for the first 15 minutes.
For an extra crispy gratin, turn on the broiler (grill) for the last 3-5 minutes. Watch it closely — the broiler burns very quickly.
Step 7: Rest and serve
Remove the pie from the oven and let it rest for 10-15 minutes before cutting. This resting period is important: it allows the layers to set and for the cut to be clean, without everything falling apart.
Cut into square or rectangular portions with a sharp knife. Serve hot, directly from the dish. Accompany with a green salad dressed with a light vinaigrette.
Tips for a perfect pie
- Firm potatoes, not soft: Boil them just until a knife goes through without resistance, but no more. Overcooked potatoes fall apart when cut and the layers blend into a mash.
- Drain the cod well: Excess water in the cod dilutes the béchamel and makes the pie watery in the center. Squeeze the cod flakes with your hands after desalting and before sautéing.
- Consistent béchamel: For a pie, the béchamel should be thicker than usual. If it flows like milk when poured, cook it a little longer. It should coat the spoon with body.
- Thin and even layers: Spread each ingredient evenly. An area with too much cod and another with none will result in uneven bites. Uniformity is key.
- Don't skimp on the final béchamel layer: The top layer of béchamel is what protects the pie and forms the gratin. It should be generous and cover the entire surface without gaps.
- Mandatory resting: The 10-15 minutes of resting outside the oven are essential. If you cut the pie straight out of the oven, the layers will separate and the béchamel will flow like a river.
- Mixed grated cheese: The blend of Emmental (which melts and becomes stringy) with Parmesan (which adds flavor and a crunchy texture) makes the best gratin.
Codfish pie variations
Codfish pie with spinach
Add a layer of spinach sautéed with garlic between the cod and potato layers. Spinach adds color, freshness, and a vegetal touch that balances the creaminess of the béchamel. Use about 300g of fresh spinach (it reduces to one-third when sautéed).
Codfish pie with piquillo peppers
Replace the red pepper in the sofrito with a layer of whole piquillo peppers, arranged over the cod. Piquillos add a subtle sweetness and a beautiful color. You can use a jar of piquillo peppers from Lodosa (best brands: El Navarrico, Cristal).
Codfish pie with mashed potatoes
Instead of potato slices, use thick mashed potatoes as layers. The result is creamier and reminiscent of a French hachis parmentier. Make the mash with the same cooked potatoes, adding a little butter and hot milk.
Codfish pie without béchamel
If you prefer a lighter version, replace the béchamel with a well-reduced homemade tomato sauce. The result is different but equally delicious: more Mediterranean and less creamy. You can also use a mixture of beaten eggs with cream as a binder (quiche style).
Codfish pie with shrimp
Add 200g of peeled shrimp between the layers for a festive touch. Sauté them briefly with the onion and garlic sofrito. They go especially well with the piquillo pepper variation.
Storage and reheating
One of the great advantages of codfish pie is that it can be prepared in advance. Here are the options:
Prepare the day before
Assemble the entire pie (all layers, béchamel, and cheese) in the dish, cover it with plastic wrap, and store it in the refrigerator. The next day, take it out 30 minutes before baking to bring it to room temperature and bake according to instructions (it may need an extra 5-10 minutes coming from the refrigerator). This is the ideal option for dinner parties: you assemble the pie calmly in the afternoon and bake it just before dinner.
Freezing
You can freeze the assembled pie (unbaked) for up to 2 months. Wrap it well in plastic wrap and aluminum foil. To bake, transfer it to the refrigerator the night before and bake it with an extra 10-15 minutes. You can also freeze the baked pie in individual portions — reheat in the oven at 180°C (350°F) for 15-20 minutes.
Leftovers
The pie keeps for 3-4 days in the refrigerator, covered. Reheat it in the oven at 180°C (350°F) for 15-20 minutes (better than in the microwave, which softens it). If you want to restore the crispiness of the gratin, broil it for 2-3 minutes at the end.
Nutritional value
Codfish pie is a nutritionally complete and balanced dish:
- High-quality protein: Cod is one of the fish with the highest protein content (18-20g per 100g) and lowest fat. It provides all essential amino acids.
- Complex carbohydrates: Potatoes provide sustained energy, fiber, and potassium.
- Calcium: Béchamel made with milk provides calcium, important for bones and teeth.
- Omega-3: Although cod is a lean fish, it provides moderate amounts of DHA and EPA omega-3 fatty acids.
- B vitamins: Cod is rich in vitamins B6 and B12, essential for the nervous system.
A generous portion (1/6 of the pie) provides approximately 400-450 kcal, with a good balance of macronutrients. It's a complete dish that doesn't need much accompaniment — a green salad and bread are enough.
Frequently asked questions
Can I use fresh cod instead of salted?
Yes, you can use fresh or frozen cod. In that case, you don't need to desalt it. Simply steam or boil the cod for 8-10 minutes, drain it well, shred it, and use it in the recipe. The flavor will be milder than with desalted salted cod, so season the béchamel and sofrito a little more.
How long does codfish pie take to make?
Counting the desalting (12-24 hours, no active work), active preparation is about 45-60 minutes: 25 minutes for boiling potatoes, 15 minutes for the cod sofrito, 15 minutes for the béchamel, and 5 minutes for assembly. Then 25-30 minutes of baking and 10-15 minutes of resting. In total, about 2 hours of active work + baking.
Can codfish pie be made without an oven?
It's not ideal, but you can do it in a wide pan with a lid over very low heat, cooking for 20-25 minutes until the béchamel bubbles and the layers are hot. You won't get a gratin, but the result is acceptable. Another option is to use a microwave with a grill function to brown the top.
Which cod is better for the pie: shredded or whole pieces?
Shredded cod is the most practical option and integrates best between the layers. It desalt quicker and distributes evenly. If you use whole pieces (loins or fillets), cook them first, shred them by hand, and then follow the recipe. The result is the same, but shredded saves you work.
Can I prepare the cod pie in advance?
Yes, that's one of its great advantages. Assemble the complete pie in the mold, cover it with plastic wrap, and store it in the refrigerator for up to 24 hours before baking. Take it out 30 minutes before putting it in the oven to allow it to come to room temperature. You can also freeze it assembled for up to 2 months.
How to prevent the pie from being watery?
The three main causes of a watery pie are: cod with excess water (drain and squeeze it well), overcooked potatoes (which release liquid starch), and too-liquid béchamel (cook it until it coats a spoon thickly). Also, let the pie rest for 10-15 minutes before cutting so the layers set.
What goes well with cod pie?
Cod pie is a complete dish (protein, carbohydrate, fat). Serve it with a green salad dressed with a lemon vinaigrette, some cherry tomatoes, or an endive salad with pomegranate. A young white wine (Albariño, Verdejo, or Txakoli) is the perfect pairing.
Conclusion
Cod pie is proof that simple cooking can be extraordinary. With humble ingredients—shredded cod, potatoes, béchamel, and cheese—you can create a comforting, flavorful, and elegant dish that works for both a family dinner and impressing guests.
Its great virtue is practicality: it can be assembled in advance, freezes perfectly, uses up leftover cod, and doesn't require complicated techniques. There are no emulsions to emulsify or critical temperatures to control—just well-made layers, a creamy béchamel, and an oven doing its job.
The key, as always, lies in the quality of the main ingredient. Well-desalted, shredded Icelandic cod provides a clean, intense flavor that no other fish can match. And when that cod meets a silky béchamel, firm potatoes, and a crispy gratin, the result is pure happiness in every bite.
Dare to prepare it this weekend. Assemble the pie on Saturday afternoon, store it in the fridge, and bake it on Sunday for lunch. Your family will thank you.
Discover more






