SAM MORRELL


ASTROPHYSICIST

Web Development for Physicists

February 17, 2018   |   Reading time: ~9 mins

I’m fortunate enough to be sitting at the intersection of two disparate fields which are rapidly hurtling towards each other. More than ever, it’s becoming important to publicise you and your research, whether you’re in academia or in the private sector. Sooner or later, this is likely going to mean you’re going to requiring some kind of online presence, which generally entails getting some kind of website. For the uninitiated, this can seem like a terrifying arena to enter, but fortunately there are a load of tools to make the whole experience easier, depending on the complexity of what you want to do is and how much time you want to throw at it.

 

Quick and Simple

Fortunately, there are a load of people from all walks of life who are in the same boat as you. To fill this niche, there are a whole host of services that have sprung up to make creating your own website as easy as possible. A couple that enter my radar a lot are Wix and Squarespace. Your choice between these will likely be determined by budget. Wix has a free-tier and Squarespace has a free trial, and a minimum of £10 per month after that. I’ve heard good things about Squarespace, as their drag-and-drop interface is supposedly second to none, but it does come at a price.

 

Roll your own simple static website

Maybe you’ve written a little HTML before and you want to have a crack at it yourself. The good news is that this is still very much a good solution to the problem, and it in fact may be one of the only ways of doing your own website depending on your hosting. This is probably the simplest way to get a new website off the ground, especially if you use a pre-built template. This approach finds you manually editing HTML and CSS files, so if you have approached these two languages before and feel at home, this is a good choice. Once you’ve edited the files as you want them to appear, you can literally just copy them onto your hosting and away you go. It really is that simple. This convenience does come with some disadvantages. First, the content of your website is tightly tied in with the structure, so if you ever decide to redesgin your website, you’ll have to re-write or do a large copy and paste operation on all of your pages. Furthermore, this approach doesn’t really lend itself to being regularly updated, as is the case with a blog. It’s definitely not impossible, but you may find it a fair amount more awkard than if you’re using something designed for blogging like WordPress; which I’ll be mentioning later on in this post.

To get you started, there are a load of fantastic pre-built HTML tempaltes that include the full CSS for the design, as well as example documents you can just copy, rename and edit to get you up and running. There are plenty website to find templates available for free and for a little money online, with various different licenses. Here are some of my favourites:

 

Enter static site generators

So you want a static website, but writing and maintaining all of the pages individually is just too much effort for you? I’ve got good news for you, there are some really great packages to help you out and automate a load of things. These are called static site generators, and a quick search will overflow with different projects that perform this task for you. The good news is that someone has written StaticGen, a convenient page to compare all of them so you can see how popular they are and get an idea of what’s out there so you can pick something that’s right for you.

I’ve used static site generators when writing basic websites for conferences hosted by the University of Exeter Astrophysics Group. My pick at the time was a package called Wintersmith. Granted, this was a couple of years ago when a load of the generators on offer didn’t even exist, but it’s still a solid choice. This node.js-based generator will have you up and running in a few minutes with a very nice, clean default theme. If you need to customise with your own flair, you can tweak the theme that’s provided, or even write your own template to completely change the way the site is laid out. If you understand markdown, GitHub users I’m looking at you, you’re ready to get creating a website with Wintersmith. To give you a feel for Wintersmith, I wrote a little article a while ago that should get you up and running with the basics. Here are a few websites that I’ve made with Wintersmith:

 

The Elephant in the Room – WordPress

I’m sure you’ve heard of this thing called WordPress before. WordPress is a PHP-based blog / website in a box. It is so pervasively used on the internet today that a reported 60 million website run atop it. Although it’s great, and I use it for this website, it’s not the panacea for everyone. For many purposes, it’s simply overkill for what you need. Another drawback is that it relies heavily on PHP and some kind of database behind it, such as MySQL; which can be a problem when using locked down hosting provided by your institution. Recently, I wrote the BBECss website and we were limited by the fact there was no MySQL server available to run from. Luckily, this where plugins come in to play and the popularity of WordPress comes to save you, because there’s a plugin called SQLite Integration that let’s the whole website run from an SQLite file. There are a few hoops to jump through, but it’s working rather well so far. Plugins really do let your website do nearly anything that you could require a website to do. If you feel comfortable with PHP code, you can even write your own in a matter of hours, and WordPress’ ample documentation will guide you through the process.

Another advantage of WordPress is the sheer number of pre-built templates there are and the ease of customising them. This website, until recently, ran Hueman which is fantastic free theme with a whole load of customisability that serves as a good start to any website. There are also a load of fantastic paid themes that will get you up and running with a professional-looking website for somewhere around £20-30. Once again, if you are keen to really tweak and customise to your hearts content, you can quickly write your own theme for WordPress, which is what I did with both of the example websites below, as well as this website. If you combine a basic template with the fantastic Page Builder plugin by SiteOrigin, you can get some very complex, responsive layouts very simply.

Here are some other websites I’ve worked on that are running WordPress:

 

Roll your own dynamic site

There are some purposes where static pages that you upload to a server are just not good enough to handle, particularly where any kind of interaction is concerned. In this situation, your best bet is to get your hands dirty and write your own website, or web app, from scratch using some kind of programming language. The problem with this approach is that it can be really daunting, even for an experienced web developer like myself. There are soooo many different projects and programming languages out there vying for your attention and claiming to be the next best thing since sliced bread.

In this situation my advice to you is simple. You’re busy with science, and you just want to get this code in a useable state and running for people to use. Although it may seem appealing to try and pick up a new programming language for the fun of it, don’t forget that you’ll potentially have to maintain this for years to come, and you’ll likely have to remind yourself how everything works every time you go to modify it, so stick to a language that you already know. For most in academia, or at very least astrophysics, Python is the natural choice; unfortunately I don’t think MATLAB or IDL has the ability to run your website. Recently, I’ve been playing around with a Python-based framework called Django. The beauty behind it is that you have to write minimal code to actually get your web app up and working, and a lot of the low-level code is dealt with by Django. Combine this with a load of third-party code to do a whole variety of things, and the fact that you can just slot your pre-existing Python code right into your website, this provides a compelling platform to begin your work. You needn’t have any security or performance concerns either, as Django is the framework behind Pinterest and Instagram, so the combination is tried and tested.

If you’re not already familiar with Python and you still want to do this, there are a load of other solutions out there. PHP is an option, but is generally less favoured for it’s complex standard library and inconsistent language features. Node.js is a good option if you have some knowledge of Javascript and have the patience to get your head around asynchronous code. Honestly, picking a language for your next web app project is a bit of a minefield at the moment, so if you feel like discussing this or anything else in this post, please do leave a comment below, or hit me up on Twitter @smorrell. I hope this was helpful, and until next time, thanks for reading.

Tags:

You Might Also Like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

Sorry, there are currently no comments for this artcle. Why not start a conversation?