The calculus of variations is employed to find steady divergence-free velocity fields that maximize transport of a tracer between two parallel walls held at fixed concentration for one of two constraints on flow strength: a fixed value of the kinetic energy (mean square velocity) or a fixed value of the enstrophy (mean square vorticity). The optimizing flows consist of an array of (convection) cells of a particular aspect ratio $\def \xmlpi #1{}\def \mathsfbi #1{\boldsymbol {\mathsf {#1}}}\let \le =\leqslant \let \leq =\leqslant \let \ge =\geqslant \let \geq =\geqslant \def \Pr {\mathit {Pr}}\def \Fr {\mathit {Fr}}\def \Rey {\mathit {Re}}\varGamma $. We solve the nonlinear Euler–Lagrange equations analytically for weak flows and numerically – as well as via matched asymptotic analysis in the fixed energy case – for strong flows. We report the results in terms of the Nusselt number ${\mathit{Nu}}$, a dimensionless measure of the tracer transport, as a function of the Péclet number ${\mathit{Pe}}$, a dimensionless measure of the strength of the flow. For both constraints, the maximum transport ${\mathit{Nu}}_{\mathit{MAX}}({\mathit{Pe}})$ is realized in cells of decreasing aspect ratio $\varGamma _{\mathit{opt}}({\mathit{Pe}})$ as ${\mathit{Pe}}$ increases. For the fixed energy problem, ${\mathit{Nu}}_{\mathit{MAX}} \sim {\mathit{Pe}}$ and $\varGamma _{\mathit{opt}} \sim {\mathit{Pe}}^{-1/2}$, while for the fixed enstrophy scenario, ${\mathit{Nu}}_{\mathit{MAX}} \sim {\mathit{Pe}}^{10/17}$ and $\varGamma _{\mathit{opt}} \sim {\mathit{Pe}}^{-0.36}$. We interpret our results in the context of buoyancy-driven Rayleigh–Bénard convection problems that satisfy the flow intensity constraints, enabling us to investigate how the transport scalings compare with upper bounds on ${\mathit{Nu}}$ expressed as a function of the Rayleigh number ${\mathit{Ra}}$. For steady convection in porous media, corresponding to the fixed energy problem, we find ${\mathit{Nu}}_{\mathit{MAX}} \sim {\mathit{Ra}}$ and $\varGamma _{\mathit{opt}} \sim {\mathit{Ra}}^{-1/2}$, while for steady convection in a pure fluid layer between stress-free isothermal walls, corresponding to fixed enstrophy transport, ${\mathit{Nu}}_{\mathit{MAX}} \sim {\mathit{Ra}}^{5/12}$ and $\varGamma _{\mathit{opt}} \sim {\mathit{Ra}}^{-1/4}$.