After being infected by chickenpox, the "varicella zoster" virus actually hides inside the nerve in the body for life. Your immunity keeps it under control and the virus is usually "sleeping" or dormant. When your body immunity drops as you age, or when you are ill, it can flare up.
And when it does, it causes shingles or herpes zoster.
The best advice is to take the shingles vaccine if you are above 50 years old. And if you have never had chickenpox before in your life, you should take the chickenpox vaccine. And obviously in that case, if you have never caught chickenpox before, there should be no way you can get shingles.
I hope this clarifies.