Staying safe in the city is very important. As many other cities in El Salvador La Libertad is highly populated but unlike San Salvador it has a lower crime rate.
The basic rules are:
Don't wear expensive jewerly.
Don't hang out in places where it looks abandoned.
If you rent a car don't rent a luxirious car.
It's the basics but other than that you will remain safe and will be a great enjoyment to you and whoever you are traveling.