How to make .desktop file to open with its own icon in sidebar

This method is applicable on creating only 1 .desktop file

I changed my Github.desktop file and added

StartupWMClass=Brave-browser

if you are using chrome then add Google-chrome instead

Next copy the default .desktop file for the browser to ~/.local/applications

cp /usr/share/applications/brave-browser.desktop ~/.local/share/applications/brave-browser.desktop

then open the copied .desktop file

gedit ~/.local/share/applications/brave-browser.desktop

and add this below the name field

StartupWMClass=brave-browser

in the case of chrome add google-chrome instead

At the end restart your gnome-session using Alt+F2 and typing 'r' followed by Enter


Result

A separate icon for github

enter image description here

enter image description here