The effects of carboxylation degree (0.3–2.4 mmol/g) of cellulose nanofiber (CNF) on the microstructure and mechanical properties of edible walnut oleogels were comprehensively examined. The oleogels were well prepared by emulsion-templated approach for potential substitute of conventional saturated or trans-fats in food products. The results demonstrated that the oil-binding capacity (OBC) and textural strength of oleogels enhanced with the increase of CNF carboxyl content, while the structural strength (G' in rheological measurement) and the resistance to shear thinning was first decreased and then increased. It possibly reflected the competition on the dominant structuring mechanism by hydrogen bonding from cellulose hydroxyl groups and electrostatic interactions from –COONa function. With the combined mechanism, oleogel with low structural strength and relatively high OBC (CNF carboxyl content of 1.2 mmol/g, OBC >83 %, G′ ≈ 7 × 104 Pa and firmness of 0.30 N) and oleogel with enough structural rigidity and high OBC (CNF carboxyl content of 1.8 mmol/g, OBC >89 %, G′ of up to 1.7 × 105 Pa, and firmness of up to 0.66 N) were both fabricated. This reveals the feasibility of regulating oleogel structure and textual properties by using CNF as the unique oleogelator and simply changing its surface carboxyl function.