Category theory novice here. I know that the free product is the colimit of a collection of groups, and that the direct product is the limit of a collection of groups.
For groups A and B, the free product A*B is the amalgam over the trivial subgroup and the direct product AxB can be understood as the amalgam over the derived/commutator subgroup [A,B]. I was wondering if anyone knew of a nice category theoretic definition for a general amalgam of groups?
EDIT: Correction, as YCor reminded me the amalgam must be over a subgroup of both A and B, so AxB is not an amalgam of A and B over [A,B].
The free product $A\ast B$ is a coproduct in the category of groups.
More broadly, if you have a third group $C$ equipped with maps to $A$ and $B$, you can form an amalgamated product over $C$, denoted $A\ast_C B$, which is the quotient $A\ast B/N$, where $N$ is the normal closure of $C$ in $A \ast C$ (more about this here). This amalgamated free product is the pushout of the diagram $(A \leftarrow C \to B)$, that is, a colimit in the category of groups. I think the pushout is the general construction you're looking for.