How to add image to hugo with local and remote

But, getting back to your original requirement:

view it on vscode and website at a same path

If the images will be used throughout the site:

  1. Create an images directory to the root of your project

  2. Add this to your site configuration

    [[module.mounts]]
    source = 'static'
    target = 'static'
    
    [[module.mounts]]
    source = 'images'
    target = 'static/images'
    
  3. Reference the image in your markdown with:

    ![alt](/images/a.jpg)
    

If your baseURL has a subdirectory (e.g., https://example.org/foo/), we will need to revisit this.