Setting up Pubby

published: 2017-08-23 16:57:39, updated: 2017-08-23 17:07:14
ontologiesPubbysemantic webtools;
Using pubby to expose resources in a dataset

Pubby is a nifty little tool that is great for exposing RDF datasets accessed through SPARQL endpoints as browsable HTML pages. What this allows is to create a populated web-page for resources available in SPARQL endpoints. Pubby uses DESCRIBE queries to populate the HTML page. To see it in action, visit [OPMW](] example pages with the Similar Words example showing all RDF links in HTML.


Pubby can be downloaded from the download page or the source can be accessed through the Github project. Usually, the latest version is advocated to be used, but in this case, I found an unresolved issue with showing RDF prefixes in the generated documents. There was a proposed solution on StackOverflow with two answers that propose adding prefixes to the config file and setting the prefixes as URI both of which did not work in my case. Therefore, downgraded from version 0.3.3 to version 0.3.2. And important change in these two versions is that pubby changed the configuration file format from N3 to Turtle. However, they both still look fairly similar, so there is not much of a change in terms of reading and configuration.

To get pubby, use curl and unzip the contents like -

# wget -O
curl -o
# use unzip or jar -xf
jar -xf

Serving with Jetty

Pubby can be served using Tomcat or Jetty, or any other mechanism of serving web containers. It does not come with a WAR file, but contains a WEB-INF folder which is ready to served. If pubby is to be served as the root which means it is directly accessible from wherever jetty is running, such as localhost:8080, then the webapps folder must contain the pubby contents as root (folder name). Otherwise, jetty can be configured to run pubby as a servelet at the desired url.

Jetty is available for download as a package, in which case, it is installed as a service, or one can download the portable application and set it up. In this case, jetty can be setup as a service using the file /etc/systemd/system/pubby.service as -

Description=Pubby server using Jetty

User=< user >
Group=< dev >
WorkingDirectory=< folder containing jetty >
ExecStart=/usr/bin/java -jar start.jar


Serving using Nginx

Once jetty is running the pubby servelet, Nginx can be configured to serve this using a proxy service as -

location /<DESIRED URL/ {
    proxy_set_header X-Real-IP $remote_addr ;
    proxy_set_header X-Forwarded-For $remote_addr ;
    proxy_set_header Host $host ;
    proxy_set_header X-NginX-Proxy true;
    rewrite ^/<DESIRED NAMESPACE SET IN PUBBY CONFIG>/?(.*) /$1 break;
    proxy_pass http://<JETTY ADDRESS>/;
    proxy_redirect off;


The pubby config file is located in the WEB-INF folder and is named either config.n3 for N3 or config.ttl for Turtle, depending on the version of pubby being used.


The starting prefixes define the prefix seen in the HTML page output, along with those used on the page.

Server configuration section

This is the section marked as an instance of conf:Configuration.

Dataset configuration section

This is an section in the Server configuration section, defined as annotations of conf:dataset property.