I recently wanted to add a bibliography to one of my blogs. The bibliography was available in BibTeX format, but I wanted to display both HTML and BibTeX. There is a plugin available, bib2html but I did not want to use it because it produces the page on fly which means that theoretically it processes the BibTeX file everytime (there may be some caching going on, but I prefer not to rely on that). Instead, I decided to use static HTML pages generated using bibtex2html, but you cannot use it directly as the links it produces will not work. Instead, I had to do the following:
(I will assume that the file to be processed is called out.bib)
- (optional) Beautify your BibTeX file using emacs.
- Open the file in emacs and select the whole text (Ctrl + Space and go to the end of document).
- Select BibTeX-Edit from menu → Operating on buffer or region → Sort entries. This will sort the entries alphabetically. This option is also available in bibtex2html, but I am not convinced it works reliably
- Select the whole text again and select BibTeX-Edit from menu → Operating on buffer or region → Reformat entries. This will format nicely all the entries. This step is quite important because otherwise the result will not look very pretty in your blog.
- Convert the BibTeX file to HTML using bibtex2html
bibtex2html --both --nodoc --no-header out.bib
This will produce three files out.html, the bibliography in HTML format, out_abstracts.html, the bibliography in HTML format with abstracts and out_bib.html the bibliography in BibTeX format. If you do not want to have abstracts do not use –both option. Check the man page of the bibtex2html command for more option.
- Install Include Me In That (html) Plugin to be able to include files in your blog entries (make sure you activate and create the IMIT_files directory).
- Copy the three files (out.html, out_bib.html and out_abstracts.html) to IMIT_files directory
- Create the first entry where you want to display the bibliography in HTML format and insert
<!--IMITH out.htmlIMITH-->
Make sure you make a note of the ID of the page. Let’s assume it is 8.
- Create another entry that will display the bibliography in BibTeX format and insert
<!--IMITH out_bib.htmlIMITH-->
Make sure you note this ID as well. Let’s assume it is 54.
- Finally create an entry for the bibliography in HTML format with abstracts and insert
<!--IMITH out_abstracts.htmlIMITH-->
Obviously writing down the ID of the page. Let’s assume it is 65.
Now the pages will display fine, but you will find out that the links between pages will not work. The next step is to edit the .htaccess file to make the work.
- Open or create an .htaccess file in the root of your WP installation and insert the following:
<Files ~ "^[\._]ht"> Order allow,deny Deny from all Satisfy All </Files> <IfModule mod_rewrite.c>
RewriteEngine On RewriteBase /
RewriteRule ^.*?out_bib.html(.*)$ ?page_id=54$1 [L] RewriteRule ^.*?out.html(.*)$ ?page_id=8$1 [L] RewriteRule ^.*?out_abstracts.html(.*)$ ?page_id=65$1 [L]
</IfModule>
# END Url Rewrite section
Save the file, and that’s it. Obviously you will need to have the mod_rewrite module enabled on your site.
You can see the results at http://www.summarizationonline.info/bibliography/


