Given a variety $X$ over $k$, we can consider which points are regular, and we can define the singular locus $\operatorname{Sing}(X)$ as the complement of the regular points in $X$.
My question is, how can we put a scheme structure on $\operatorname{Sing}(X)$? Is it always true that $\operatorname{Sing}(X)$ is closed subscheme? Can someone give me a reference of how we define singular locus?
Here's how to do it in the affine case. Suppose $X = \text{Spec } k[x_1, \dots x_n]/(f_1, \dots f_m)$. The condition that a point is singular can be phrased in terms of the rank of the matrix with entries the partial derivatives $\frac{\partial f_i}{\partial x_j}$: generically this rank takes a particular maximum value, and it drops at precisely the singular points.
This dropping condition can be expressed in terms of vanishing of minors, and so is an algebraic condition: if $M$ is a matrix, then it has rank strictly less than $k$ iff all $k \times k$ minors of $M$ vanish. These minors cut out the singular locus as a closed subvariety of $X$. I'm not sure if there is a preferred scheme structure, though.