Traditionally, the energy shaping for mechanical systems requires the elimination of holonomic and nonholonomic constraints. In recent years, it was argued that such elimination might be unnecessary, leading to a possible simplification of the matching conditions in energy shaping. On the other hand, the partial feedback linearization (PFL) approach has been widely applied to unconstrained mechanical systems, but there is no general result for the constrained case. In this regard, this paper formalizes the PFL for mechanical systems with kinematic constraints and extends the energy shaping of such systems by including systems with singular inertia matrix and non-workless constraint forces, which can arise from the coordinate selection and PFL. We validated the proposed methodology on a 5-DoF portal crane via simulation.