You need a ranking evaluation of S for each level on the same difficulty. I suggest to don't stress about it in the beginning of yours first playthrough.
First an S rank is gained as a mean among five points:
- Time (usually under thirty minutes),
- Combos (you need to gain an evaluation of S or S+ while using combos; it's easier when witchcrafts are upgraded),
- Finisher (it's not totally clear to me but I guess that it depends on the number of finishers you do),
- Kills (you need to reach a set amount of kills; it's different for each level),
- Tries: (number of time you died and retried).
Acquiring three S and two A give you a total rank of S.
The levels are replayable through chapter select.
Upgrading the witchcrafts to level three is extremely important for S rank in combos, finishers and time.