We are generally taught and come to assume that a compass points true north and south. Unfortunately, there is error in this. A compass needle can only align itself according to the magnetic field of the earth, and this field may deviate considerably from the true north and south. In some locations the deviation may be as much as 20 degrees east or west of true north-south. If you are serious about “treasure hunting” with a map and compass, much less sailing out of sight of land, you will need to correct for this deviation. There are maps that show the correction necessary for any location. Type into your browser:
magnetic declination maps images
A further difficulty is that the magnetic poles of the Earth gradually migrate over the years as shown here (scroll down): https://www.dw.com/en/magnetic-north-pole-is-changing-faster-than-forecast/a-47043665
Therefore, be sure you have a recent declination map.