Adding search to a write.as public blog

Updated info after this post was created: CJ Eller's blog post explains how to custom style the search bar with javascript and CSS. He also provides further details on this in two posts on the write.as community forum: post 1 and post2.


Searching a public write.as or writefreely blog is easy to do, compared to searching private blogs or anonymous posts. It just takes adding an html iframe snippet to a blog page's source code, no javascript or CSS is needed. The blog must be public, if it's a private blog it won't work. For an example, take a look at this blog page: https://plaintextproject.online/articles.html. Then view the source code for that page (typically, right-click on the browser page and select View Source). You'll find the following snippet embedded in that code:

<iframe src="https://duckduckgo.com/search.html?width=250&site=plaintextproject.online&prefill=Search The Plain Text Project" style="overflow:hidden;margin:0;padding:0;width:308px;height:40px;border-radius: 15px 50px 30px 5px;" frameborder="0"></iframe>

The DuckDuckGo search engine is used. Replace two parts of that code:

  1. Replace plaintextproject.online with either your personal domain name or your <blog>.writeas.com blog.

  2. Replace Search The Plain Text Project with your custom search message.

A couple points:

  1. You can search other public blogs or web sites if you want. It doesn't have to be your own blog.

  2. Since this snippet is html with no javascript or CSS, this will work in an write.as/writefreely anonymous post also. However, you would have to search a public blog or site. Anonymous posts and private write.as blogs are not searchable with this technique (though see point #4 for a different way to search them).

  3. If your blog's url is in the form write.as/blogname rather than blogname.writeas.com, that might work as well. I quickly did a test and it appeared to work.

  4. If your write.as/writefreely blog is private or if you want to search your anonymous posts, you can still do it using, for example, a PHP program in combination with data downloaded from the write.as API. This technique is outlined here. The technique described in that post requires that you have a web server with PHP support. If you don't have that, CJ Eller, community manager for write.as, wrote a glitch.com app that will do the search on your blog(s) and anonymous data downloaded via the write.as and/or writefreely API.

  5. Of course, this html iframe snippet will also work on other web site pages besides just those created on write.as or writefreely.

Thanks Plain Text Project for giving an example of how this can be done.