B.G 3.20
karmaṇaiva hi saṁsiddhimāsthitā janakādayaḥ। lōkasaṅgrahamēvāpi sampaśyan kartumarhasi ॥20॥
Indeed, King Janaka and others could attain perfection and be in that state by performing prescribed duties alone. You are only eligible to perform your duties, having an eye towards the welfare of the world.
Gīta Bhāshya 3.20
The knowledge of Brahman alone can give liberation. Performance of one's duties is a means to such knowledge. There are no other alternative means. 'karmaṇā' - while continuing to perform prescribed duties. Sentences that praise visiting holy places, etc. are meant to inspire ignorant towards right means, and do not directly result in liberation. King Janaka belongs to the category of Jnanins in the context of the Vedic scriptures.
ācārōpi astītyāha - karmaṇaivēti।
Even the conduct practiced (by ancestors) is relevant, is indicated by 'karmaṇaiva' verse.
karmaṇā saha karma kurvantaḥ ēva ityarthaḥ। karma kr̥tvaiva tatō jñānaṁ prāpya vā। na tu jñānaṁ vinā। prasiddhaṁ hi tēṣāṁ jñānitvaṁ bhāratādiṣu। 'tamēvaṁ vidvān' ityādi śrutibhyaśca। atrāpi karmaṇāṁ jñānasādhanatvōktēśca 'budidhayuktaḥ' iti। gatyantaraṁ ca 'nānyaḥ panthāḥ' ityasya nāsti। itarēṣāṁ jñānadvārāpi avirōdhaḥ।
'karmaṇā' word's definitive meaning is 'while continuing to perform respective duties'. Knowledge is got only after performing the duties. Without it, there is no knowledge. They (king Janaka and others) are famous indeed as knowledgeable (jñānin) in the epic Mahabharata. "He alone is the wisest" - there are such Vedic testimonials as well. Even in Gīta verse 2.51 'budidhayuktaḥ', the enjoined duties are said as a means to knowledge. The Vedic testimonial "nānyaḥ panthāḥ" i.e. "there is no other means", rejects any other path. There is no opposition elsewhere to obtain liberation with the help of knowledge.
yatra ca tīrthādyēva muktisādhanamucyatē -
and, where visiting holy places is recommended as a means to liberation:
"brahmajñānēna vā muktiḥ prayāgamaraṇēna vā। athavā snānamātrēṇa gōmatyāṁ kr̥ṣṇasannidhau॥"
"Liberation can be attained either through the knowledge of Brahman or through death in Prayāga. Alternatively, by simply bathing in the river Gomati in the presence of Lord Krishna."
ityādau tatra pāpādimuktiḥ। stutiparatā ca। tatrāpi hi kutracit brahmajñānasādhanatvamēva ucyatē anyathā muktiṁ niṣiddhya -
- such statements refer to freedom from results of accumulated sins. They are meant to praise such austerities. Indeed, even there, to an extent, such acts are advocated as a means to obtain the knowledge of Brahman. Without it, liberation is not possible.
"brahmajñānaṁ vinā muktiḥ na kathañcidapīṣyatē। prayāgādēstu yā muktirjñānōpāyatvamēva hi॥"
"Without the knowledge of Brahman, liberation is not possible at any cost. Indeed, visiting holy places such as Prayag are suggested to gain knowledge, as a means to liberation."
ityādau। na ca tīrthastutivākyāni tatprastāvēpyuktam jñānaniyamaṁ ghnanti। yathā kañcid dakṣaṁ bhr̥tyaṁ pratyuktāni
- there are such statements as well. When statements that praise holy places are presented, they do not contradict the rule that knowledge (of Brahman) is a must (for liberation). It is similar to addressing an able servant with praise, saying:
"ayamēva hi rājā kiṁ rājñā"
"This one indeed is king. What you say, O King?"
ityādīni।
-and such other statements.
yathāha bhagavān-
Therefore, the Lord said:
"yāni tīrthādivākyāni karmādiviṣayāṇi ca। stāvakānyēva tāni syurajñānāṁ mōhakāni vā। bhavēnmōkṣastu maddr̥ṣṭēḥ rnānyatastu kathañcana॥"
"Such statements about pilgrimage places are eulogies to praise topics related to actions meant for the ignorant and deluded. The liberation happens by having the vision of mine alone, not otherwise."
iti nāradīyē।
-stated thus in Nāradīya Purana.
ataḥ aparōkṣajñānādēva mōkṣaḥ। karma tu tatsādhanamēva ॥20॥
Hence, by the transcendental knowledge alone, liberation is possible. The prescribed duties are only the means to such knowledge.