WordPress Multisite Oops

I’m using Multisite WordPress for most of my WordPress sites. I’m also using Nginx, so the .htaccess files don’t do me any good.

My sitemap.xml files seem to be overwriting each other in the host site folder, so the sitemap.xml for this site may show as one of the others, I presume based on which one was updated last.

I’ll have to figure that out later.


Migrated Jekyll to WordPress with Ruby and API

A few years ago I migrated this blog from WordPress to Jekyll, and now I’ve migrated it back again. I want to be able to quickly post notes to this my notetaking site, and I’ve been using WordPress more lately.

How did I migrate Jekyll to WordPress? I made a Jekyll liquid template to make the API bodies and a Ruby script to insert them into the WordPress API.

WordPress API Authentication

First I tried copying the cookies from Chrome dev console and the nonce from the page source for API authentication, but I couldn’t get that to work.

So I installed the basic auth plugin (from WP-API GitHub) and activated it, and then I could use a simple username and password for my WordPress API calls.

After the import was complete and all the new posts were working, I deactivated the basic auth plugin for security.

Jekyll Template for WordPress API Post Creation

Since Jekyll is in Ruby, I just used Ruby for the API calls. I also made this export template to make the post bodies. You may want to change the author ID and/or change the statuses or format as desired. This leaves comments and pingbacks disabled and publishes the post as author ID 1 with the standard format. I named this export.json .

layout: null
sitemap: false
    "posts": [
    {% for post in site.posts %}
            "date_gmt": {{ | jsonify }},
            "slug": {{ post.url | jsonify }},
            "status": "publish",
            "title": {{ post.title | jsonify }},
            "content": {{ post.content | jsonify }},
            "author": 1,
            "comment_status": "closed",
            "ping_status": "closed",
            "format": "standard"
    {% endfor %}

I then built the site with bundle exec jekyll build. Then I edited the output json file in _site/ to remove the last comma in the file to make it valid json.

Ruby Script to Upload to WordPress API

I made the following Ruby script to read the _site/export.json file and upload to the API. Ensure to put the password in the environment variable SECRET and then export SECRET if in Linux/Mac. Also edit the script for user_name, protocol, site, and json filename


require 'net/http'
require 'json'
require 'time'

user_name = "jim"
password = ENV['SECRET']
login_cookie = ""
wp_nonce = ""

protocol = "https"
site = ""
api_path = "/wp-json/wp/v2"

init_header = {
    # 'X-WP-Nonce' => wp_nonce,
    # "Cookie" => login_cookie,
    'Content-Type' => 'application/json',

uri = URI("#{protocol}://#{site}#{api_path}/posts")

http =, uri.port)
http.use_ssl = true

json_text ="_site/export.json")
posts = JSON.parse(json_text)

req =, initheader = init_header)
req.basic_auth user_name, password

    .each do |post|
        # Ensure date is in ISO8601 format
        post["date_gmt"] = DateTime.parse(post["date_gmt"]).iso8601
        req.body = post.to_json
        result = http.request(req)
        puts result.body

Migrating Jekyll Pages to WordPress Manually

The above scripts only migrate the posts. It should be possible to modify them to handle pages, too, but I only had two pages and just created each manually and copy-pasted the content from the Jekyll-built pages into the WordPress new page editor.


Syntax Highlighting Notes

I just changed the Jekyll Rouge syntax highlighting theme on my new site, Practical Code Use. Jekyll’s default is oddly pinkish, and I like the dark themes. First I tried monokai, but some of the colors look odd, especially with PowerShell. So I switched to Dracula which looks better for my purposes.

Pygments themes work with Jekyll’s Rouge, but I had to add some extra styling to get the background color right:

 figure.highlight pre code, pre.highlight code {
    color: #f8f8f2;  /* .w taken from Text.Whitespace */
    background-color: #282a36;
 .highlight {
   background: #282a36;
   @extend %vertical-rhythm;
  .highlighter-rouge & {
      background: #282a36;

But it still doesn’t look quite right. I tried searching for how to convert Visual Studio Code’s themes to Pygments/Rouge. I didn’t find anything on-point, but I did find an interesting suggestion at this blog to use the Productivity Power Tools VSCode plugin to copy syntax-marked html from VSCode, the advantage being that VSCode better understands each language and has more sensible highlighting because it understands the code where Pygments and Rouge are just matching syntax rules.

In Options, Productivity Power Tools, HTML Copy you need to set EmitSpanClass to true and EmitSpanStyle to false.

I haven’t tried this yet, but I’d like to, at least for some languages.

I went ahead and put Dracula here, too. The scss above is using it. Yeah, it even looks funny for scss.

So I decided to go looking for this Productivity Power Tools plugin. I can’t find it in the extensions marketplace inside VSCode, but I know you can copy and paste syntax-highlighted code. It just took me a few minutes to figure it out, and it’s hackish although I’m sure there’s a better way. I copied the text from VSCode and pasted into a GMail compose window, then right-clicked and inspected, then copied the parent div and pasted it here:

figure.highlight pre code, pre.highlight code {
color: #f8f8f2; /* .w taken from Text.Whitespace */
background-color: #282a36;
.highlight {
background: #282a36;
@extend %vertical-rhythm;
.highlighter-rouge & {
background: #282a36;

Yeah, that looks much, much better. But if you look at the source, it has hard-coded rgb styles instead of classes. It would be interesting to have class-based highlighting, then I could recolor it after the fact.

Next-day update: Oh, I just realized it’s Rouge that’s the problem. Prism.js and Pygments look pretty good, but Rouge makes some very odd choices that just don’t make sense and don’t help understanding the code. I tried rougify from Rouge 3.4.1, the latest version, on PowerShell and SCSS and it still highlights funny. Rouge does well with Ruby, but for the two languages I needed it for yesterday it sucked.


Soft 404 in Google Search Console

I was digging deeper into Google Search Console today and noticed I had “soft 404” errors for several items.

What is a soft 404? It is when Google tries to access a page successfully, but it has no content.

I had to look that up. The urls it had for soft 404s for me were ogv and webm video files. I navigated to the url, and they just downloaded instead of playing.

After some investigation I found that the MIME type / Content-Type was set to binary/octet-stream. I’m serving the files from AWS S3, so I used the S3 console to edit the metadata to change the Content-Type to video/ogg or video/webm as appropriate.

Now when I go to the urls they just play in the browser instead of download, and hopefully Google will quit seeing them as soft 404s.

I think the reason Google saw them as blank content is that I had links to the alternate video formats, and since they had an inappropriate and vague content type, Google assumed it should be a web page but couldn’t render it as one. With the updated content type it should now understand that the link is to video content and not a page.


DVR saga part 7

From part 6

  • No codec for live playback : This is an annoying concept, but it’s as much Microsoft’s fault as NextPVRs, maybe moreso. I can install a 3rd-party codec (need to vet them to ensure I don’t get one with malware) and get live playback working

Oh…I already have at least two MPEG2 decoders on my to-be replacement box. I’m watching live playback now in my computer room. So that problem is solved.

The tuner driver software has a codec, although I’m not clear why my main DVR doesn’t have them as it’s the same vendor. I guess I just need to re-run the install CD. And my to-be replacement has a DVD playback codec available from Microsoft. I’m not sure how that got on there, but in any case this problem is solved.

Also, on a mostly-unrelated note, I’ve had some time sync issues on my network that sometimes caused the DVR(s) to get as much as 5-7 minutes fast or slow. I fixed that today. Odd combination of 3 virtual machines being the authoritative time for the network, but the hardware host kept resetting their clocks. The hardware host is theoretically syncing its time to these VMs, but in reality they were kind of fighting and flipping time back and forth seconds to minutes at a time.

Time to watch the Cowboys…and maybe I’ll have the TV synced with the radio broadcast for the first time this season.


DVR saga part 6

From part 2

Well I’m not thrilled with NextPVR so far. Not that I’ve tried to mess with it much, but it doesn’t just keep working. I’m not sure if the fault is with Win10 or NextPVR, but it will get stuck in some sort of sleep mode and stop recording. Also it doesn’t seem to auto-free recording space.

I think I just figured out what’s going on with the sleep/wake problem. I don’t know the solution yet, but….

As I’ve said many times, I’m watching less and less TV. So the few times I’ve kicked the DVR since upgrading to Win10 I’ve generally just rebooted it without looking at it to get it working. This time I went and investigated why it wouldn’t wake and realized it’s getting stuck and failing to reboot properly during Win10 upgrades…which is a problem I had with my “main” PC…which has the same motherboard model…I have four of that model, but only two have Win10 (the others being servers), and both of those consistently (?) get stuck during reboot during automated Win10 updates.

And I just stumbled upon a possible workaround while typing that: until I figure out what driver/setting is preventing reboots I might be able to force manual updates. Actually I’m not sure on that as Win10 home has mandatory updates. I have the pro/enterprise version, so I might still be able to update manually when I can force the reboot and not have it freeze up when I’m not paying attention.

I was going to swap out to a faster PC for the DVR, but I was going to use the other PC that freezes, and in fact the only motherboards I have available in a case that fits the tuners are this model motherboard.

Anyway, so my current issues and solutions with my NextPVR install:

  • Freezing during updates : not a NextPVR issue. Can find the driver issue or possibly disable automatic updates so I can ensure the reboot happens when I manually update.
  • No codec for live playback : This is an annoying concept, but it’s as much Microsoft’s fault as NextPVRs, maybe moreso. I can install a 3rd-party codec (need to vet them to ensure I don’t get one with malware) and get live playback working
  • Free space not freeing up : I haven’t dug into this at all. Right now I’m just deleting football games before recording the next one, and delete some other big shows. If I swap PCs I’ll probably start with a fresh recording drive and figure it out then.

I didn’t originally have interest in the streaming feature, but I’m starting to like getting a web stream of live TV. The only problem here is that the existing CPU isn’t fast enough to transcode reliably, so the PC swap will fix this, too.


DVR saga part 5

I’ve toyed around some today and read quite a bit. I think my dreams might be crushed, or at least they aren’t worth the hassle.

What I really liked about WMC was that I didn’t have to mess with it. I could record stuff, watch and pause live TV, and watch recordings with very little hassle.

Apparently my TV is picky about DLNA, and even if I get it working I don’t think it’s going to be as good as an experience as having NextPVR or whatever on a PC playing directly to the TV. And PC-direct-to-TV is going to be the best quality and response for live DVR watching and even recording playback no matter where the tuner actually is. (For now, anyway.)

If I rethink my main goals, there are two of them:

  • Record OTA TV for later viewing
  • Pause, delay, FF/RW live TV, specifically sports

And at this moment I think my least-hassle approach to that will be to get NextPVR live playback working (need to install an MPEG2 encoder) and ensure that will work for me. Then see if there are remaining reliability problems that might be fixable or at least something I can monitor automatically.

I might put the tuners in a faster PC than they are now so I can use some of the streaming features better.


DVR saga part 4

My thoughts on this topic rapidly evolve. Now that I’ve gone through a bunch of hard drives and files I’m confident I could lose any of the three Win10 PCs without losing anything important, I realize I could use them to test out various DVR / media server software.

More and more I think I would like a “back room” TV tuner server and be able to at least play stuff on the TV and computers via DLNA and/or a program.

Some software thoughts:

  • MythTV – Most of my problems with this were playback, but that was years ago and I’m not wanting to use it to play. It’s worth another look as a backend server.
  • NextPVR – Has suddenly started behaving and may turn out to be the default, least-trouble if it continues to work. Supposedly can serve media via DLNA, and even if it can’t another server could serve its recordings I expect.
  • SageTV – Has very little mention / mindshare out there, but used to be proprietary, got bought by Google (!) in 2011 and was fully open sourced about a year ago. Worth a look if for no other reason than Google and open source, but curious why it appears to be under the radar.
  • Plex – Meant to be a server. Parts are proprietary, but it might do what I want to do with the free parts. Might be worth an install on a now-spare PC.
  • Emby – Had a lot of hype in recent months/years. I know very little about it, but it’s supposedly a server-oriented thingy, too.

I’m currently more in favor of trying out existing stuff than rolling my own. I have 3 TV tuner cards and at least one USB tuner. 2 tuner cards are in the NextPVR box, but that still leaves me two other trial tuners, and heck I might even be able to temporarily stop NextPVR and install something else on the current DVR box.


DVR saga part 3

So far in my homebuilt DVR adventures, WMC was the least problematic / most reliable, but MS has killed it off, and it wasn’t problem-free or spouse/kid/visitor friendly to use because you had to have all the inputs set up right and sometimes had to fix the resolution.

Since my last post I’m toying with the idea of building my own distributed DVR software from scratch where a Linux scheduler fires up a recording process. I’d have to manage the schedule (via Schedules Direct), the tuners and the disk space. I wouldn’t even worry about playback or live TV; that would be done with another product.

Hmm, this is sounding doable. I am presuming there already exists a command-line simple recorder I could leverage. I could make the interface a REST API and write a simple web page / phone app interface that is easily replaceable by anyone who cares.

I’m even starting to have an idea on how to handle live playback with only a few seconds’ delay…I could segment the recordings into many files and stitch them back together for playback. Actually I wouldn’t make a player; I’d make a streamer. Hmm…

Edit: In my early research I stumbled across a notice that MythBuntu is ending. That’s what I used to get stuff set up easily. It would take more work to get MythTv working without it.

Edit 2: This is a pretty good overview of to-buy and build-your-own options:


DVR saga part 2

Well I’m not thrilled with NextPVR so far. Not that I’ve tried to mess with it much, but it doesn’t just keep working. I’m not sure if the fault is with Win10 or NextPVR, but it will get stuck in some sort of sleep mode and stop recording. Also it doesn’t seem to auto-free recording space.

And just now, the web interface completely changed and it appears to be a differently branded product, so I’m not sure what’s up with that.

I’m still watching football games live with no live DVR but managing to record the games.

I watch more YouTube than TV these days, and the difficulty with actually watching the recordings on the main TV makes me want to just put the recording box in a back room and use a possibly-portable player–or perhaps even the TV itself–to watch any recordings. So I might check into a different recording system based on Linux and try to tie that activity in with my job-hunting beef-up activities.

Come to think of it, I’m not that thrilled with Kodi, either. I find it easier to use VLC player to watch stuff.

In any case, whatever I do next, I think the model is a recorder that isn’t directly connected to the TV (one less bit of equipment to keep around). …come to think of it, I play games and Blu-Rays seldomly enough I think I’d rather simplify the by-TV equipment…if the TV had better speakers I’d consider moving the fancy stereo…hmmm maybe I should buy a speaker bar and be done with it.

I’m definitely in the mood to go minimalist. Well, less cluttered, anyway.