How to unlock your bootloader, install a custom recovery, and root your LG Nexus 5 with Android 6.0.1

Follow this guide:

Be sure to reboot between unlocking your bootloader, and installing the custom recovery. (Steps 7, and 8) To prevent bootloop via this article:

PSA: Make Sure You Reboot After Unlocking Your Nexus Or GPE Device’s Bootloader

If you do get the TWRP boot looping tryuing to execute open script recovery and just bootlooping, flash the original recovery image, and reboot all the way until the welcome screen. Then flash the custom recovery again.