1

I uploaded a smart contract written in Solidity to github but it is not syntax highlighted. Instead it looks like a regular text file. I would like syntax highlighting to be shown on Github. How do I achieve that?

  • I think this is a very valid question and relevant to this forum. I think it should be reopened. – Thorkil Værge Apr 27 '18 at 13:19
4

You need to tell github that this file is a Solidity file. Github will not recongnize .sol files automatically at the moment. Add this line to your .gitattributes file:

*.sol linguist-language=Solidity

If you do not have a .gitattributes file you need to create one and place it in the root directory of your git project.

  • That doesn't seem to work anymore. Is there a newer method that works? – schemar Mar 4 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.