Preparing your environment for SGF


This document will explain you how you can automatically launch your favorite game browser when you fetch go games from this WWW site. The document will also explain how to set up your http server to provide a similar service for your customers.

An overview of the topics:

The Go game mime type

The mime type is what a webserver attaches to data to enable clients (Firefox, Opera, Internet Explorer, ...) to clearly recognise the kind of data and enable them to take the appropriate actions to visualize it. For example, HTML pages are emitted with mime type text/html, plain text with mime type text/plain, PostScript with mime type application/postscript, and gif images with mime type image/gif.

To enable your browser to recognise electronic Go games this server emits game records with a special mime type (of course choosen carefully to make it differently from any other mime type which you will ever encounter on the web):


The leading x- denotes that this mime type is not officially registered (trying to register it would only have a small chance to be accepted since the general applicability of the mime type is rather limited as go players will realize).

Receiving Go games

Your can instruct your software which you use to read mail, news or browse the web what to do with documents which have special mime types. The default action for unknown (unmapped) mime types is to display the contents of the file as text in the browser window or to prompt the user where to save the data on disk.

However, in general you prefer to automatically start up a dedicated program to deal with the incoming data in a more sophisticated way (like starting up an sgf editor for go games).


To configure your UNIX environment (I will deal with Windows in a minute) and in particular your web browser for the mime type attached to the go games there is only one thing you need to do. Add the following line to the file ${HOME}/.mailcap:

    application/x-go-sgf;	/path-to/showsgf %s
(Please note the semi-colon after the mime type.)

This line requests your mime type aware software (like your browser) to start up /path-to/showsgf to visualize application/x-go-sgf data (with the filename as command line argument). Of course you would adjust the exact location of the showsgf shell script to suit it to your particular situation.

Windows (& UNIX)

If you are on a Windows platform or if you are running Netscape-4.0 or newer then you can configure the mime-type handling for Go games within Netscape:

  1. Open the Preferences dialog
  2. Open the Navigator submenu
  3. Select the Applications entry
  4. Check the mime-type list for the SGF mimetype (application/x-go-sgf)
  5. If it's there select it and select "edit...", if you cannot find it select "add...". A new dialog will be shown.
  6. Make sure the entry reads:

    Next, mark the line with Application and enter the path to your SGF editor program and add a space plus the string "%s" on UNIX systems or "%1" on Window systems:

    or (Windows)

    This requests that the browser will start up the application and pass it the SGF game record ("%s" or "%1"). If your SGF editor has special flags to specify the SGF game record then you should add them. For example, the UNIX program cgoban needs the "-edit" flag so the Application line would then read:

Please consult your local webmaster for any further support in case you need it.

Try it out

After you have added the above line (and forced your browser to reload the .mailcap file, either by the supplied interface or by restarting the browser) you can preview the game below on your screen just by clicking it, try it!

IGS-94 tournament: jiroo-jansteen
An interesting game featuring the rare (6,3) opening
and lots of fighting.

Serving Go games

The way to accomplish that a web server emits groups of files with a special mime type usually is simple. The procedure explained here is valid for the NCSA httpd and Apache compatible servers. In case you are running another server please check the documentation coming with that server first.

The procedure:

  1. First name all go games similarly by giving them the same file name extension (for example, all go games on this site end on .sgf).
  2. Next, you request the server to emit all files ending on this extension with the mime type of your choice (in our case application/x-go-sgf). You can accomplish this in two ways:
    1. By adding the following line to the file called mime.types which is read by the httpd server during startup:
      application/x-go-sgf sgf
      To request the server to re-read the changed mime.types file you can send the parent httpd a HUP signal (kill -1) or execute the Apache startup script apachectl with the argument restart.
    2. By adding the following line to a file named .htaccess located in the same directory where the datafiles are located or in one of its parent directories:
      AddType application/x-go-sgf sgf

    Both methods bind data files ending in suffix .sgf to mime type application/x-go-sgf.

Dealing with local go games

While Go games received from this site using the http:URL service have the application/x-go-sgf mime type attached to them things are slightly different when you use the file:URL service to load local games into your browser (since in that case no http server is serving the files). However, it is easy to also get this case right. Simple add the following line to the file named ${HOME}/.mime.types:

application/x-go-sgf sgf
Your browser will read the ${HOME}/.mime.types file during startup.

As a nice side effect your mailer, news-poster and possibly some other communication software might import go game files automatically using encapsulation techniques as displayed here:

-- encapsulated
Content-Type: application/x-go-sgf

PB[Takemiya Masaki]
PW[Cho Chikun]
-- encapsulated --

This syntax allows the software which is used to read this mail to spawn a go game viewer with the game data as input.

Page creation: Jan van der Steen