A self-template synthesis of defect-rich WS2 as a highly efficient electrocatalyst for the hydrogen evolution reaction.