The Neighbor

I held the elevator open for an elderly lady entering the building. She thanked me, and saw the floor that was already active. Her apartment was on the same floor, she said. I exclaimed “Neighbors!”, to which she smiled and said, yes. On reaching the floor, we discovered that we live in flats directly opposite to each other. We got talking; what I did and where I was from. Turned out, she lived in New Delhi with her husband for 5 years! I told her about my internship there for a couple of months. She could even tell the neighborhood she was in, which was pretty close to where I lived.

Incidents like these make you realized that the world’s not that big of a place. This entire conversation took place in German (at least I tried to) which was kind of a big deal for me. New language skill put to good use!

Experiences With Macbook And MacOS – Part 2

In the part 1 of this post, I wrote about getting a new laptop from/for work. I also dug into the similarities and differences between my old Thinkpad T440 and my work computer, a Macbook Pro.

Now, after more than 6 months of using the Macbook as my primary computer, I switched back to my Thinkpad. In this article, I’ll get into what I missed from the Thinkpad (which was slightly different from what I thought I’d miss) and what the tipping point for the switch was. This is a personal account, and as such, is shaped by the way I perceive things. Probably it would have been very different if I’d used a Macbook from an early age and made my first shift to a GNU/Linux distro 6 months ago.

Control

You lose a lot of control from over your system when you run a proprietary operating system (and most software on it). That feels obvious when I write it that way, but we often forget or take things for granted when using a GNU based operating system that we realize only when we switch to something like MacOS. There are ways of customing MacOS, no doubt, but they aren’t nearly as powerful (or simple) as the ones available on most distros on Linux.

It is worth noting that control isn’t strictly needed, and is a preference. But if you do prefer to be able to tinker with the way your system looks, feels and works, then you’ll find that preference better respected on this side of the fence.

UI

No matter how hard I try, I just couldn’t get myself to like the gestures and animations in MacOS. My brain is kind of stuck in the old school menus of Windows XP/7 (and hence, xfce). Also, having spent a lot of time customizing my status bar in xfce, I couldn’t help but feel under-equipped trying to do the same on MacOS. Not a huge fan of the bubbly semi-transparent UI scheme either.

New learnings

Depending on how you see it, it can be regarded as both good and bad. Most things just work out of the box in MacOS. It is like buying a fully furnished house. That frees you from having to think about things like setting up Wifi, Bluetooth, screen brightness and so on. All keys on the keyboard do what they say they do, sound works out of the box, and even if you break something, you can always take it to someone to get it fixed (Not very sure if/how the last one works, but guessing there’s some kind of support available to Macbook customers).

While all this sounds perfect (and it is, if that’s what you need), most of what I have learnt about computers is through fixing stuff that I broke while tinkering with it. A couple of months of MacOS usage made me realize that I’m not learning even a fraction of what I’d have otherwise did if I was using a broken system, full of shortcomings. I’ll let a quote from Moxie Marlinspike’s The Worst to summarize my thoughts.

…no matter how much research they do, a partisan of the best might not ever know as much about motorcycles as the partisan of the worst who takes a series of hare-brained cross-country motorcycle trips on a bike that barely runs, and ends up learning a ton about how to fix their constantly breaking bike along the way. The partisan of the best will likely never know as much about sailing as the partisan of the worst who gets the shitty boat without a working engine that they can immediately afford, and has no choice but to learn how to enter tight spaces and maneuver under sail.

Speed disappointments

So, in exchange of all of that, I assumed, I’ll be using a system that’s super smooth and faster than anything I’d ever used. Nop. Not even that. It was just as fast as my old computer. I think newer CPUs and hardware in general are quite overrated for most people’s use cases. If you know even a tiny bit of what you’re doing (and aren’t part of that minority of computer users that actually needs powerful hardware), you can make a 5-10 year old computer work more or less the same way as any modern computer.

Community

While I moved away from my Thinkpad, and by extension, the *nix community, it didn’t move away from me. I was constantly reminded of how customizable my desktop could’ve been at r/unixporn, how over 10 year old laptops are still daily drivers of many at r/thinkpad, how easy getting your operating to do something for you used to be at StackOverflow and what good documentation should look like at ArchWiki. All in all, I missed the community.

Tipping point

While all of this was coming to my notice slowly, a major turning point was hearing Hakun Lie and Bruce Lawson at DevBreak two months ago. There, I got to know about web standards and where things are heading. It was fun to get reminded of the things that excited me about web in the first place. Then, Bruno walked me through a project of his that used some of the newer web apis. I was blown away, and honestly a little embarrassed to have forgotten the passion with with people talk about the web and engineering things on it. I just wanted to get back to my old world.

Final thoughts

So I got back on my Thinkpad running a fresh installation of Arch and i3, and writing this on the same. Trying to get the function keys working never gets old for me, and the joy of having found the solution on the internet, implementing it and getting it to work and in the process actually understanding what happens when you press a function key is something you learn by actually doing it. This, and countless such experiences are what make it so much fun to be in the GNU/Linux ecosystem.

Thank you for reading!

Let’s Talk About The Disadvantages Of Living Close To Work

My recent post was about finally getting a permanent flat in Berlin, especially one within walking distance of my workplace, which must’ve been a dream of many. It certainly was one of mine. Coming from Mumbai, where a commute of an hour or two is no biggie, Berlin has been a pleasant surprise.

None of my commute here has been more than 30 minutes one side, and the current one is 12 minutes walk, 7 on bike. My one day’s commute distance in Mumbai would now be equal to 3.75 working months, or roughly 75 days of commute here in Berlin (of course, I took a train, but you get the idea). But that’s also partly because I travelled an insane distance from home to work back in Mumbai.

So while everything sounds all sunshine, I could see some disadvantages of this setting after living here for three weeks. A thing to note here, before we get into the fun stuff, is that when I say disadvantages and problems, I say that in a purely first world problems sense. It really is a privilege to even have such problems, and no, this is in no way comparable to the struggle of trying to push your body inside an overcrowded Mumbai local train on Ghatkoper station at 8 in the evening after a tiring workday.

So, having taken care of the internal guilt, let’s get started.

No time to read

My college commute was a good 90 minutes in a single direction. And I was lucky because I’d just get in the train, grab a good seat and start reading. It would either be a physical book or a PDF in my phone. That’s the best part of having long commutes. It is so boring that you don’t need to tell yourself to read, it just happens.

Now, my days are exactly of the same length and I am working for roughly the same number of hours. But I have no idea where those extra hours that I’d spend in trains went. They say gas molecules take up all the space available to them. Guess that’s true of work and time as well. I’m barely left with time to read, and when I do, I don’t (unless I force myself, which isn’t the best long term strategy).

Fewer food options

When you live at one place, and work at the other, you essentially have two different worlds. So during the week, you go to one set of restaurants, and over the weekend, you’re free to try the other set. But when you live so close, you end up going to the same places even during the weekends. It is just a weird feeling to be walking the same paths and going to the same places to eat that you would during the weekdays with your colleagues.

No alternate mode of transport

Living at all the other places, I would have the default option of taking the subway. Sometimes, I’d take one of those rented bikes. Occasionally, when the day is good, I’d just walk. Now, it is just walk or bike, which, while not a terrible thing, doesn’t leave much room for variation. There’s no place in between work and home where you’d just stop by to grab a bite, or a river where you’d spend ten minutes just looking at the boats passing. It’s just Home > Work > Home.

Less motivation to WFH

There used to be good reasons to work from home. I could save commute time, have different food options and probably go to a park in the evening. Now, not much time saved and I end up eating at the same place.

More frequently late to work

I always knew this would be the case, even back in college. The people who were super late to classes were the ones who lived the closest. I can feel the same happening to me now. I find it more difficult to reach the office at a particular time than when I used to commute by subway. During college, since I took the same train everyday, I’d reach perfectly at the time I had planned (unless the trains messed it up, which wasn’t unusual). I guess even this is more of a discipline issue which I need to fix.

In closing

If I sounded like a spoilt teenager in this post, that’s probably fair. If you find a place to live close to your workplace, take it by all means. It is worth it, and will be a good test of discipline and time management for you. Plus, not having to take public transport or having a place to grab a bite on my way from work, I manage to save good money.

Finally, working full time and reaching home at 5 in the evening is a dream for a tech worker. It is like you have another day after you get back. I use mine to learn a new language, which is only feasible in a setting like mine. I hope you found this article fun to read, that’s what I meant it to be.

Thank you for reading.

HTML For Semantics, CSS For Visual

The best way to learn is to teach, they say. I totally agree, and that’s one reason I have so many articles on my blog explaining random topics. Part of the goal was always to understand the topic better myself.

I got reminded of it while I was preparing for a workshop on introduction to web technologies for my fellow Berliners who wish to get into tech. Then something interesting happened. I found the root of a problem that I was struggling with for some time at work. I will jot down some notes of this entire experience, and try to tell you about the lessons learned.

Our Styleguide

We maintain a frontend styleguide (think: company-specific UI library). We have many HTML elements and CSS classes that make our text, buttons and cards look the way we want them to look across the webapps. There’s a little issue. Most textual styles are defined on HTML elements. So to get a large heading styled with our predefined font-size, font-family, color and a bunch of other styles, one would just use h1 (notice: no class needed).

This worked for us until now, and wherever a big heading was required, we would just throw in an h1. Similarly for paragraphs, lists and other textual elements. This made a lot of sense in the past as accessibility or SEO weren’t a concern. But things changed.

Multiple h1s

It all started when our contracted SEO agency told us that we had two h1s on a page. We looked at the page, and it made total sense. There were two ‘headings’ of super large size, and our styleguide’s h1 made total sense from a purely visual perspective. But the second heading was just a title in large font. It had no semantic significance. Now, our product’s main title and some random text have the same precedence on the page.

This is bad for SEO, no doubt, but this is also bad for screen readers and all mini browsers (like Apple Watch and the like) which rely on the HTML to convey semantic information, and not visual.

Thinking and problem solving

I went to our designers and had a discussion. I could just hack and overwrite the styles, but that wasn’t the point. I asked what could be done. We could change the design, create a new class the resembles heading-1s and then use that on a span and so on. But we couldn’t think of why we’ve met with this problem. Maybe we’re missing something, something obvious, we thought.

Conference on web basics

I attended a developer conference a couple of weeks ago. There we had the good fortune of listening to Hakun Lie and Bruce Lawson. What struck me, apart from how much they cared about web standards and saving the web from the bloat hell that we’re hurtling towards, is how much one can accomplish just by sticking to web standards. One of the examples used was of the Apple Watch, and the website in question was developed much before anyone imagined a browser on your wrist. If one just uses semantic HTML, one can be sure that their website would work on any device, whether in existence or yet to arrive. And just like that, millions of well-designed websites started to work on the special Apple Watch browser.

This is important to note because there are usually multiple ways of doing something on the web. More often than not, there are a couple of right and many wrong ways. Part of our job as web developers is to ensure that our website isn’t just pretty visually but also correct semantically and structurally. This is to futureproof our creation.

The workshop

I was preparing for this workshop and thinking of various ways I could introduce web development to complete beginners. I referred to some nice articles and tried to understand the meaning of HTML and CSS myself. I tried to understand why reset.css and normalize.css are used, even though I’ve been using them for years. I came up with interesting analogies to explain the basic pillars of the web and as a result, improved my understanding of these constructs.

Lightbulb moment

After the workshop, when I went back to my codebase, I could see the problem staring right back at me. We had styled the HTML elements, and not created separate classes that we could then attach to our elements. This is the result of forgetting the basics and doing something the wrong way because it saves you from writing class="" for every HTML element, which to be fair, doesn’t seem that bad when you don’t differentiate between HTML and CSS and use a combination of the two to get the design right.

Conclusion

There are a couple of conclusions for me from this article. One is to learn and follow web standards. Semantic HTML is not at all hard, just some 120 tags in total. Then, understand what a markup language means, and how the semantics of a document is different from how it looks or works. Learn the rules of CSS selectors and how cascading works. Learn that HTML and CSS are declarative, and use them as much as possible. Only where it makes sense, introduce Javascript. In general, keep abstractions to a minimum.

Thank you for reading.

Berlin Flat Search Experience

I arrived in Berlin some six months ago. From that point until now, I have lived in three different parts of the city and I’ve finally found my permanent nest in the fourth one. I want to share some things about this entire journey, from my Airbnb to this flat, and retrospect some interesting experiences and observations I had along the way.

So yes, that’s four moving-ins that we’re talking about in the span of 6 months. Four times I had to pack, carry, unpack, repack my 40-ish kg mini-world. To be honest, I didn’t quite enjoy any of the shifting experience at all, possibly because I was doing it using public transport and possibly because those aren’t enjoyable experiences in general.

That said, I really loved all of those flats and their respective neighborhoods. Berlin has many colors, and you only see them when you live in its different districts. We’ll get into some of those later on in this post, but first let’s start with the search process itself.

https://en.wikipedia.org/wiki/Boroughs_and_neighborhoods_of_Berlin

Search methodologies

In Berlin, there’s a shortage of apartments to live in, and an abundance of people on the hunt for one. It is almost like searching for a job. You show up for viewings at the time decided by the owner of the flat. First thing you notice is, especially if it is a half decent flat, there are a dozen more people wishing to get the same flat. The owners (or people appointed by them) judge if you can be the ideal tenant (based on many things, not the least of which are your payslips and SCHUFA scores). After the viewing, you go home and wish you get accepted by the almig…umm the landlord. Repeat this several times a day for a couple of months.

I just couldn’t stand this entire process. I went for a couple of listings, but gave up. Too much work. For that reason, all of the previous apartments I’ve lived in were some sort of referral homes. And that’s one big reason it took me so long.

Getting over previous flats

What I found surprising was how quickly I got over the previous flats, even though while living there I really wanted to make them my own. Every apartment, except for the first one, was handed over to me with some dangling hope that it would be signed over to me. And I would really get attached to the apartment, only to later find out that due to so and so reason, I won’t be getting it. While that’s heartbreaking in the moment, it was interesting to retrospect on how adaptive our brains are. Couple of days after moving in, I would just forget about the previous place and start over again.

Starting over again was a very typical process; finding a nearby supermarket, finding restaurants, exploring the area for parks and places of interest during the weekends. A week later, everything is in autopilot; from commuting to work to refilling groceries. Also interesting is how cryptic a new place seems in terms of streets and direction, but a month later I could really get around the neighborhood without even thinking. Yet another proof of the power of repetition.

Amenities and flat size

I was searching for a flat for myself. I preferred to not live in a shared flat (or a WG – Wohngemeinschaft as it is called in German). An important thing to note is that many flats come empty, that is, without any fittings. Not even a kitchen is fitted. I wanted a somewhat furnished flat as that made more sense economically. Furnishing usually involves a bed, cabinet, fitted kitchen with fridge and other kitchen stuff, washer. Dishwasher in rare cases. That’s more than sufficient to get started.

Flat sizes are measured in square meters (1 sqm is 10.something sq feet). They usually have one or two rooms (zimmers in German, excluding kitchen and bathroom). The flats in my budget were quite diverse, from 25 sqm one room to 65 sqm 2.5 room ones depending on the neighborhood and public transportation options. I decided to deprioritize size and focus on furnishing in the flat and being close to work and city center.

Neighborhoods

This is my favorite part of the search: Being able to experience different neighborhoods. As I mentioned, Berlin offers many shades of itself if you move to different districts in the city. The people change, and so does the food and the way the buildings look. I was fortunate enough to live in both east and west Berlin. Over the past six months, I lived in Friedrichshain, Kreuzberg, Mitte-Prenzlauerberg and now Mitte.

Friedrichshain was the first. Where I lived, it was very silent. Not many stores or restaurants. It was an ideal place to live once you’ve been in the hustle and bustle of the city for years. For me, it was a bit depressing, especially after coming from India. I didn’t explore much of it, but now that I’ve spent sometime here, I can see it had a lot of options for food and other stuff.

Bergmannkiez – Kreuzberg was next. This is a fancy area, very touristy but still good to live in. Very diverse crowd with many cultures living together. There is this street called Bergmannstrasse that had great food options. Tempelhof airfield was nearby and this was the time I got into outdoor activities and hanging out with my colleagues and their friends. There are nice Biergartens (Beer gardens) that people go to to meet friends and play indoor games. Tempelhofer Feld is still my favourite place in Berlin.

Just go there on a weekend, lay in the grass and read a book or something

Third was Mitte-Prenzlauerberg area. This is a upmarket locality with nice cafes and cake places. I didn’t quite like the food there (think bland food, loads of salad and sprouts. In short, way too healthy) but I liked the neighborhood and people in general. This was also on the same street as Mauer Park where I’d spend a lot of time over the weekends.

Fourth and current place is in the heart of Mitte, literally meaning center in German. Nothing special, but very center. Around a kilometer from Alexanderplatz and my office. Now I can reach work in less than 10 minutes, which is nice. Coincidentally, this is almost exactly in the middle of all the previous places and I can go to all of my favorite parks and snack bars from the previous places easily. As a bonus, I can see the Fernsehturm right from my living room!

The window is my gateway to daydreaming, especially when it turns dark. Reminds me of my desk at LaughGuru in Mumbai. As you can tell from the LEDs and candles, I try hard to make my house look pretty.

Learnings

If I had to start over again, I’d do a couple of things differently. I’d probably put in a bit more effort into the hunt as opposed to completely relying on connections all the time (which is fine, but seriously limits the scope of your search). Facebook groups and sites like ebay-kleinanzeigen.de are good places to search, and much less commercialized compared to immobilienscout24 where each listing has dozens of takers.

But when you think about it, how else would I have gotten the experience of living in those many different areas right after coming here, within six months. Back when I used to look at Berlin’s map, I would wonder how long it would take to have a general intuition of where everything was, the way I had for Mumbai. This entire apartment search debacle fast forwarded this process and I know parts of the city that I’d have otherwise not known.

In closing

While writing this post, I realized that by wishing for things to work out well right away, we actually miss out on a lot of interesting experiences. Was it inconvenient to miss the connecting flight and luggage on my way to Berlin or not finding an apartment for six months straight? No doubt it was. But looking back at those experiences, would I trade them for a smoother ride? definitely not.

Have a good week ahead and thank you for reading!

What’s In A Domain? 5th Anniversary Of Blog

While there’s nothing specific I plan on writing in this post, I’ll share a few things as they come to my mind. 6th of June, 2014 was the day I bought this domain. I must admit, I was a bit embarrassed to have my name in the domain but I quickly got over that.

Image from 8th June, 2014 ♥ 5 years with Cloudflare

Those were the times when I was learning about programming, friendships and college life in general. This is from one of the outings to Mumbai from college.

I want to believe that our cameras weren’t so bad back then. Probably just over-editing

I also started writing on Ghost.io, before moving to Blogger and then Jekyll. Here’s a screenshot of the first post (which is now lost).

If being super embarrassed by your past self a good indicator of progress, I think I’m doing pretty well

And I also liked showing off my stuff, whatever little I had back then. I used to borrow laptops and computers from friends and would try to set up ‘testing labs’ in my bedroom. Most of such labs would end up being used for playing NFS Most Wanted. One of my favorite showoffs was showing off code or terminals.

One such labs from back in May 2014. Obsession with GNU was real, especially the cooler distros in infosec like Backtrack (now Kali).

Good times. It is nice to have this blog and bits of data here and there from the past, otherwise it is easy to forget these little memories.

Whether this is the first article that you read on my blog, or you’ve been following from some time, I must thank you. You’re as much part of the blog as the content itself, and I have not a shred of doubt when I say that this blog has been one of the most worthwhile investments I’ve made in my life so far.

See you in the next one!

The Worst By Moxie

It is no secret that I’m a huge fan of this guy. For my first snippet, I’d like to put down a few quotes from one of my favorite articles of his.

Often, I browse shopping sites like Amazon for no reason, looking at exotic gadgets and accessories, convincing myself I need them. Slowly, I am convinced and they end up in my cart, staring back at me. During such an impulse, I open this particular article and give it a read. It helps cure that temporary surge of materialism. I highly recommend you read “The Worst” by Moxie Marlinspike.

…an emphasis on the consumption of material goods can easily translate into a life of generalized consumption. A whole language can start to develop around not just the consumption of goods, but the consumption of experience: “We did Prague.” “We did Barcelona.”

“The best moments of my life, I never want to live again.”

…no matter how much research they do, a partisan of the best might not ever know as much about motorcycles as the partisan of the worst who takes a series of hare-brained cross-country motorcycle trips on a bike that barely runs, and ends up learning a ton about how to fix their constantly breaking bike along the way.

The basic premise of the worst is that both ideas and material possessions should be tools that serve us, rather than things we live in service to. When that relationship with material possessions is inverted, such that we end up living in service to them, the result is consumerism. When that relationship with ideas is inverted, the result is ideology or religion.

Thank you for reading!

Be Easy On Yourself

I have been fortunate enough to have worked alongside some very smart and kind people in all the companies that I’ve been part of. And in all those people, I always noticed a common element. You instantaneously have an appreciation for how wise they are from the way they talk about random things, the way they think. It almost makes me wonder, especially as a computer nerd, what did they do to get a thought process like that?

And to clarify, I’m not just talking about software engineers. I’m talking about managers; product, marketing and people from other domains. So this isn’t a bias for people good with code. They might not have been the best in their respective domains, but it didn’t seem to matter. They were all super pleasant to be around and working with them was always a joy.

Initially, that was weird for me. How can someone be so good at what they do and not be super famous? Why are they not millionaires or working in, I don’t know, Google or something? I remember thinking about all these things, but not knowing the reason. Now, after gaining some maturity and finding a lot of time to just pause and ponder over such questions, I think I have some possible answers.

Ever since I was a kid, I was fed this idea of what a successful person is supposed to be like. He’s rich, he’s famous, he’s smart. He can afford whatever he wants, has a big house, lives life without any struggles and works for a large corporation as an executive. If you want to be called successful in life, you ought to become like him. I’d imagine many of the children brought up in cultures and societal structures like mine had the same idea of what success looks like.

So when I got out of this environment and met people who felt like they were doing well in their lives on the whole; are happy doing what they do, are influencing and making a difference in the lives of people around them and so on, my trained mind had internal conflicts. On one hand, it felt like they’re pretty successful and happy with what they do. On the other, my definition of a successful person didn’t seem to match them. What was happening?

It was simple. Just as we sometimes accept a very specific definition of health, intellectual or creativity, and regard anything that deviates from this definition as disabled, dummy or mundane, I had this one definition of successful and everything other than that was just a compromise at best.

But I was massively wrong. It had to be wrong all along. We’re all different, and trying to fit everyone under one umbrella was doomed to be a failed generalization. There are as many ways of being successful as there are humans and ways to be alive, and each one of us can define it for ourselves what that means for us. From drawing doodles to collecting rocks, only you can judge if you’re successful. This isn’t to undervalue those of us who work super hard and are actually successful in my old, partial definition of success. This is to broaden the definition, my definition, to accommodate all the variations we see in life around us and appreciate it all.

The world isn’t a level playing field. Just like in video games, the game of life can be played on easy, medium or difficult setting. Unlike in the video games, you don’t get to choose it. Some people are playing the same game as you at a very different difficulty level, and there’s not much that can be done about it. The least we can do, is not make it even crazier.

In closing

I’m very glad about this shift in my perspective over the past half a year or so. This serves multiple purposes.

  • One, I am more open to exploring and appreciating the ideas of fun, weekends, vacations and in general living a good life from the perspectives of people who’ve been brought up very differently than I was.
  • Two, I don’t lock myself in this tunnel-visioned world view that just because someone is not a senior-something by the time they reach a particular age, they’re not ambitious, talented, smart or whatever.
  • Three, I get to experience a lot of new, wonderful aspects of life that I never knew existed; laying in the grass and feeling warm sunlight on your skin, running a marathon, skateboarding, gifting, making people smile and laugh, and being grateful for little things in life.
  • Four, I detach the concept of a person’s value from the money they’re making. It changes a whole lot, and makes me look at people around myself in a completely new light. A light which emphasizes on someone’s skills, values and thoughts over their paychecks and job titles.
  • And five, it makes me more empathetic in my daily life while talking to someone who’s not like me.

To close this essay, I’d like to come back to the title of this post. Take it a little easy, little slowly. You’re in a car driving on a never ending road that meets the horizon in the distance. Keep an eye out for where you’re heading, but make sure you don’t miss the scenes on the sides, for those are real. What lies at the horizon might not.

Cheers, and thank you for reading!

Search On Jekyll Blogs

Static site generators are great. No fuss, pure purpose. I use Jekyll because that’s what Github supports the best. But these days, with services like Netlify, you have many options. This site aggregates the top ones, so give it a look if you’re planning on setting up one for yourself.

staticgen.com is a nice website to find a static site generator right for you

One thing that’s tricky with static site generators is search functionality. Since there’s no backend, whatever you plan on searching has to be generated the same way other content is. Often, that means iterating over all posts and creating a json file which you can fetch in the frontend and do offline search.

While that works, it doesn’t give you full content search (if you include content in that json blob, it will grow in size and get slower with each new post). But full content search is exactly what you need at times. I needed content search, and I spent sometime researching the options that exist. Below, I’ll list a couple of them, not necessarily only the ones that offer full content search but each suited to some specific use case.

Netlify Functions

Netlify has managed cloud functions thingy (serverless) and it works on top of AWS Lambda. It is very simple to write a function with netlify, and when you push your code, the functions are deployed as well. It comes with a free tier which runs on a 128mb instance. Pretty low, and would time out in 10 seconds if you give it a lot of work.

Netlify picks functions from a directory and pushes them to aws internally. Now, we need our json file to be present in Netlify lambdas directory before the push happens. We can make use of a simple node module Front Matter that would take our _posts directory and return a nice json with frontmatter and body parsed. Then we take this json and write it to a file which we can then import from our lambda function.

Now, for the search function, we can use something like FlexSearch that does offline searching. Just that we’ll use it in the lambda.

And you should update your build command in netlify’s netlify.toml file (or web interface) to run the node script before the jekyll build step.

  $ npm run create-json && jekyll build

Keep in mind that the free tier is very low-duty. Try to strip down content by filtering stopwords and doing other optimizations.

On the frontend, you make a GET request with query parameter q to this endpoint like you would with a regular backend search.

Algolia (or any search as a service)

I’d start with stating why Algolia didn’t fit very well for my use case. Their record (think each individual post text plus metadata) size limit is 10kb, so if your content is frequently more than that, and you want it to be searchable, Algolia might not be the best for you. But if you don’t need full content search, or if you write little posts that are usually less than 10kb, it might be a good option to look into.

Essentially, you create a searchable index on Algolia (simply upload a json file or use their jekyll-algolia gem), and use their client side libraries to query this index. They have a nice and simple web interface to do it manually or just use a script to automate it via their APIs.

Like mentioned before, you can implement a two step deploy process to Algolia that removes stopwords and duplicate words from the text before pushing the index. That way you can still fit the record in 10kb.

AWS Lambda

Netlify search uses AWS Lambda internally, but netlify only offers a couple of tiers ($0, $25 and a custom plan for $500 paying customers). On the other hand, AWS has a wide variety of lambda instance sizes and charge per usage which makes it super cheap.

What you lose in this case (compared to Netlify functions) is that you have to set up the CI pipeline yourself from scratch. So no automated pushing of the functions along with your static site. If you have a lot of searches, or heavy search queries, AWS Lambda is the way to go. For very simple and light weight use cases, Netlify isn’t a bad choice. Note that Netlify also deploys to AWS, so your function will work on either service with little to no modifications.

ElasticSearch

This is a complex solution when compared to the others on this list. Essentially you create a simple app on, say Heroku with a simple GET and POST interface. You can pair this app with a free Bonsai ElasticSearch instance. The POST will push data to this instance and GET will fetch search results.

The middleware Heroku app is to simple prevent our Bonsai credentials from getting into the wild. I didn’t think this was a good solution for simple use cases because of the maintenance factor. The reason we use Jekyll (or any static site generator) is to keep things simple, and this search solution is hard to sell to people like us.

In closing

As I found out, there are many ways of implementing a good search feature on a Jekyll (or any statically generated site). I’ve left out details of the implementation as I couldn’t find time to do so but what I learned was that just knowing that these options exist helps a lot. So the next time I’m thinking, “hmm, I’d like to have a search here, but not sure how to handle the logistics that come with it”, I’d already have a few options!

Thank you for reading.