Do we really know that the origin of gold was in a supernova explosion?
Up until the last few years that was the generally accepted explanation, but things have changed somewhat due to two developments.
About half the elements heavier than iron (including gold) must be produced via rapid neutron capture - the so-called r-process. This is not under debate, but the main astrophysical site of the r-process is.
(1) It has become increasingly difficult to produce sufficient amounts of some of the heavier elements (including gold) in theoretical models of supernova explosions. The problem is that the exploding material is just not neutron-rich enough, unless very specific conditions to do with rapid rotation, magnetic fields and low overall metallicity are met.
(2) The simultaneous observation in gravitational waves (by aLIGO) and electromagnetic waves of GW170817 has revealed that merging neutron stars are possibly a more effective site of the r-process element production. The GW detection clearly provides evidence that this event was produced by merging neutron stars and detailed infrared spectroscopy of the light from the accompanying "kilonova" explosion has revealed the presence of heavy lanthanide elements in the ejecta, which are a product of the r-process.
Now there are three difficulties in leaping to the conclusion that all the gold is produced by merging neutron stars. It may well be the dominant source but firstly, it remains to be established what the rate of these events are in the local universe, let along what the rate of these events were before the Sun and solar system were born. There are order of magnitude uncertainties here, although one can make another inference/extrapolation to assume that merging neutron stars are responsible for short gamma ray bursts and use the rate of these to estimate the cosmic history of these events. Secondly it is uncertain just how much r-process element production takes place. This cannot be very well established from the observations of just one event and there are considerable theoretical uncertainties. Thirdly there are observations of very old halo stars that have atmospheres that are enriched with r-process elements. It seems unlikely (though perhaps not impossible) that there would have been time before the birth of these stars to produce this enrichment via the merging of neutron stars, which is a process that can take hundreds of millions or even billions of years. This there may be some proportion of r-process elements that are produced in certain kinds of core-collapse supernovae.
Some more details and references can be found in my answer to this closely related question.
But maybe your question is broader than this. How can we be sure that heavy elements are produced inside stars? The answer to that lies in a long process of theory, followed by observation, followed by refinements to theory, but the basic answer is that we can see examples of very old stars born right at the beginning of our galaxy. These stars contain almost no heavy elements at all (less than a ten thousandth of what we infer to be in the Sun). We can also measure the presence of (some) heavy elements in the ejecta from high mass stars and we can also see fresh heavy elements appearing at the surfaces of giant stars that has been mixed up from the centres of the stars where they are being produced in nuclear reactions.