There seems to be some misunderstandings at work.
When Alauddin Khalji's conquest of Gujarat took place:
In early 1299, Alauddin sent Ulugh Khan and Nusrat Khan to invade Gujarat, where the Vaghela king Karna offered a weak resistance. Alauddin's army plundered several towns including Somnath, where it desecrated the famous Hindu temple.
As it is a tale that merely states that Hamirji Gohil would defend the temple – not "save it":
There is stirring tale of Hamirji Gohil, The 16 year old newly married chieftain of Lathi, Who sacrificed his life in 1299 defending the Somnath temple from the attack of Alauddin Khalji . Hamirji gohil's cenotaph still stands at the entrance to the fabled somnath temple. Hamirji had said, "Bhale koi aave na aave maari saathe, pan hoon jais Somnath ni sakhate" (Whether anyone comes or not comes with me, but I will go to protect Somnath).
This is therefore a heroic myth for hindu-nationalists – whereas Muslim sources are apparently equally ascerbic for praising war and destruction.
But that brings up a problem. This myth and man with the name and motto re-appears in that movie – centuries later:
15th Century A.D :: Veer Hamirji Gohil, The Warrior of Gujarat Who Sacrificed His Life To Defend Somnath Temple From Army of Mahmud Begada
Summaries In the early 15th century Gujarat, Muslim rulers invaded temples of India to loot the wealth. Somanath temple was attacked by the sultan of Gujarat. Veer Hamir single-handedly defended the temple against the forces with his friends.
There is this stirring tale of Hamirji Gohil, the 16-year-old newly-married chieftain of Lathi, who sacrificed his life in 1401 defending the Somnath temple from the attack of Muzaffar Shah. Hamirji Gohil’s cenotaph still stands at the entrance to the fabled Somnath temple.
–– Yash Gohil: "History of Gohil", 2011.
The recorded dates for this temple on the net offer:
Northern India had ceased to attract Mahmud, for the spoils of its most wealthy temples were already in his treasury. But the rich and prosperous province of Gujarat was still untouched, and on October 18, 1025, he started from Ghazni with his regular troops and thirty thousand volunteer-horsemen for the temple of Somnath, situated at the distance of a bow-shot from the mouth of the Saraswati, by the side of which the earthly body of Lord Krishna had breathed its last.
Ghazni Mohammed descended on Somnath in 1024 when the temple was so prosperous that it has 300 musicians, 500 dancing girls and 300 barbers to shave the heads of visiting pilgrims. There is a description to this effect by Al Biruni, an Arab traveller. After a two-day battle, Ghazni Mohammed carted off its fabulous wealth and also destroyed the temple, thus setting a precedent of Muslims destroying the temple and Hindus rebuilding it, for it was razed again in 1297, 1394 and finally in 1706 by Aurangzeb, the Mughal emperor who was notorious for such acts.
Mahmud entered the temple and possessed himself of its fabulous wealth. 'Not a hundredth part of the gold and precious stones he obtained from Somnath were to be found in the treasury of any king of Hindustan.' Later historians have related how Mahmud refused the enormous ransom offered by the Brahmans, and preferred the title of 'Idol-breaker' (But-shikan) to that of `Idol-seller' (But-farosh). He struck the idol with his mace and his piety was instantly rewarded by the precious stones that came out of its belly. This is an impossible story. Apart from the fact that it lacks all contemporary confirmation, the Somnath idol was a solid unsculptured linga, not a statue, and stones could not have come out of its belly. That the idol was broken is unfortunately true enough, but the offer of the Brahmans, and Mahmud's rejection of the offer, is a fable of later days. The temple, which stands today, was built in the traditional pattern on the original site by the sea, thanks to the efforts of Sardar Vallabhbhai Patel.
–– Ghazni sacks Somnath Temple, Indhistory
Also Romila Thapar: "Somanatha and Mahmud", Frontline, Volume 16 - Issue 8, Apr. 10 - 23, 1999 India's National Magazine – (from the publishers of THE HINDU).
After that destruction the temple was rebuilt:
Minhaj-as-Siraj tells us how Mahmud became widely known for having destroyed as many as thousand temples, and of his great feat in destroying the temple of Somnath and carrying off its idol, which he asserts was broken into four parts. One part he deposited in the Jami Masjid of Ghazni, one he placed at the entrance of the royal palace, the third he sent to Mecca, and the fourth to Medina.
The fourth temple was built by King Bhoja Parmar of Malwa and Bhima Chalukya of Anhilwada Patan during 1024-1042 A.D.
In 1169 A.D. the fifth temple, along with its integrated complex rose again during the reign of Kumarapala, the Chalukya King of Anhilwada Patan, Pasupat Acharya Bhava Brahaspati being the head of the shrine. Chalukya King Bhimadeva II added Megalanad Mandap in 1216 A.D. In 1287 A.D. further additions were made to the temple by Pasupat Acharya Tripurantaka under Sarang Deva Vaghela, King of Gujarat.
Then came the invasion of Allauddin Khilji's general Alaf Khan, who captured and once again destroyed the temple and idol in 1296 A.D. According to Taj-ul-Ma'sir of Hasan Nizami, Raja Karan of Gujarat was defeated and forced to flee, "fifty thousand infidels were dispatched to hell by the sword" and "more than twenty thousand slaves, and cattle beyond all calculation fell into the hands of the victors".
–– Leaves From The Past: "Somnath - The Symbol of National Pride", IndiaFirst Foundation
A similar account is found on Somnath History Pre-20th-Century History
Another source to consult would be:
Jaymall Parmar: "Somnath Ane Hamirji Gohil", 2017. (Which I cannot access).
But after reading
Vir Hamirji Gohil
Vir Hamirji Gohil will be remembered for his great sacrifice and bravery in order to protect the pride and glory of somnath temple. In the history of India, Hamirji Gohil was sole king who sacrificed his life and fought against entire Mughal army for saving the somnath temple from invasion.
I'd stop researching this as actual or factual history anyway.
The peculiarity of myths that are in clear conflict of logic depending on region and source is well illustrated and argued for examination in the theoretical disputation of
–– Harald Tambs-Lyche: "The region as object of discourse: an example from India" - Social Science Information, 1994.- (PDF)
A source for the various claims about Gohil to check against would be
– Samira Sheikh: "State and Society in Gujarat, c. 1200-1500: The Making of a Region", Dissertation, Wolfson College, Oxford University, 2003. (PDF)