Migrating an existing hugo blog

Hello,

I have a few questions, I hope someone can help me. I have read over the documentation and I really don’t understand.

I have a blog www.richinsql.com which is my main technical blog, I haven’t posted there for a little while for a number of reasons but would like to bring that blog into Micro.blog.

  1. Is it possible to do?
    If the above is true how do I do it without loosing all my links, content and images?

  2. Once all my content is in, is it possible to bring over my theme? I have made a number of changes to the theme I use here and would love to carry on using it.

  3. Is it possible to link more than 1 blog to post to an existing single Mastodon account?

I fear these may be obvious questions but I am in a pickle with the migration and don’t want to “mess up”

Thanks in advance
Rich

1 Like
  1. Is it possible to do?
    If the above is true how do I do it without loosing all my links, content and images?

If you’ve got a standard Hugo site with a pile of markdown in a content/posts folder and images wherever, you should be able to import. There’s an import (click the three dots next to your blog name on the Posts page, select import, there’s a “pile of markdown files” import option). It will automatically grab images that are referenced in the Markdown from the web and import into Micro.blog and replace those references.

  1. Once all my content is in, is it possible to bring over my theme? I have made a number of changes to the theme I use here and would love to carry on using it.

I use an entirely custom Hugo theme. They almost all work here with small modifications to allow for things like setting the micro pub endpoints. That said, if your theme is highly reliant on content types other than “posts” and custom front matter, you may have some issues. Micro.blog uses pretty much strictly the Post content type without a lot of work, and does not make custom front matter accessible.

Your theme’s compatibility is not really knowable without looking at the code of your site, but under the hood, Micro.blog is straight Hugo, it just doesn’t expose 100% of the Hugo functionality.

One thing that will not be possible in your case, without loading redirects by hand, is keeping the precise URLs you already have (I don’t think… unless @manton does something special on import). That’s because you’re using pretty URLs (no .html extension, and Micro.blog does not allow for that) and because you appear to have custom slugs that don’t quite fit the Micro.blog format. While MB does allow for redirect URLs, mass redirects are not quite so simple. It’s not like just adding nginx patterns.

  1. Is it possible to link more than 1 blog to post to an existing single Mastodon account?

Yes, when you click account it specifically gives you the option of adding additional blogs. The switching can be a bit wonky in places, but you can do that for sure.

1 Like

Interesting, I got all of the markdown files, put them in a zip, uploaded them and nothing happened. Waited 20 minutes, still nothing.

The logs suggest it attempts to import 1 file and that is it, nothing else, no errors.

If you’re willing to share one of these Markdown files, using a link or just copy-n-paste it here, I can take a look.

Hey, @sod

Here you go :slight_smile: I think it has something to do with the date, the markdown file name is also 2022-05-09-trace-flag-3226.md

---
title: SQL Server Trace Flag 3226
date: 2022-05-09T09:00:00.000+01:00
author: Rich
layout: post
categories:
- sqlserver
draft: false
tags:
- SQLServer
- DatabaseAdministration
- Advanced
---

An issue with SQL Server that you might not be aware of is that every time a backup is sucessfully completed on an instance a message is recorded to the SQL Server Event Log

![](/img/trace-flag-3226-1.png)

This happens for all backup types and is default behaviour. If for example you take frequent log backups this can become problomatic becuase the log will be full of messages that are not really all that useful for the management or diagnosis of the instance itself. With Trace Flag 3226 you can change this behaviour. 

This trace flag has been in production since SQL Server version 2000, so it has a long standing in the code base. 

Microsoft have this in the documentation for this flag;

    By default, every successful backup operation adds an entry in the SQL Server error log and in the system event log. If you create very frequent log backups, these success messages accumulate quickly, resulting in huge error logs in which finding other messages is problematic.

    With this trace flag, you can suppress these log entries. This is useful if you are running frequent log backups and if none of your scripts depend on those entries.

### Enable The Change Immediately 

You can enable the change immediately without forcing an engine restart by running the following command in SQL Server Management Studio 

DBCC TRACEON (3226, -1)


![](/img/trace-flag-3226-2.png)

This will change the behaviour with immediate effect but if the instance restarts the default behaviour will be enforced. 

### Enfore the change 

Load up SQL Server Configuration Manager - if this is not in your start menu, below is the locations of where you can find it.

| Version      | Path      |
|--------------|-----------|
| SQL Server 2019 | C:\Windows\SysWOW64\SQLServerManager15.msc      |
| SQL Server 2017      | C:\Windows\SysWOW64\SQLServerManager14.msc  |
| SQL Server 2016     | C:\Windows\SysWOW64\SQLServerManager13.msc  |
| SQL Server 2014 (12.x)      | C:\Windows\SysWOW64\SQLServerManager12.msc  |
| SQL Server 2012 (11.x)     | C:\Windows\SysWOW64\SQLServerManager11.msc  |

![](/img/trace-flag-3226-3.png)

Once there, right click on the SQL Server Service, Select Properties then select Startup Parameters 

![](/img/trace-flag-3226-4.png)

Enter the following trace flag into the statrup parameter box

-T3226


![](/img/trace-flag-3226-5.png)

once you have typed it into the box provided press add

![](/img/trace-flag-3226-6.png)

 Now press apply, you will get a warning saying the change won't take affect until the server is restarted but if you ran the DBCC command from above this can wait until a more conveniant time. 

### Check The Change

Now that the change is implemented, lets take a backup and see what happens 

![](/img/trace-flag-3226-7.png)

As you can see, SQL Server is no longer creating entries in the event log for sucessful backups. 

### Watch out!!!

If you have scripts or monitoring tools that rely on them entries being present in the log, you might not want to do this but if your scripts or monitoring soloutions make no use of them and you have high backup frequency or just don't want to see sucessful backup messages in your logs this is definatley a recommended change. 

### Make It Standard

It is good practice to enforce this startup parameter on all new instances of SQL Server - if you have a checklist, add this to it it makes diagnosing your instance all that much easier. 

I successfully got that post imported using this reduced YAML front matter:

---
title: SQL Server Trace Flag 3226
date: 2022-05-09T09:00:00.000+01:00
author: Rich
layout: post
---

I can’t tell you why that works, though, there’s something Micro.blog doesn’t like with the other variables. Maybe @manton has an idea?

But now that you have a known working example, you could try re-adding the other variables and see if you find a combination that works.

Thank you for that - I have lots and lots of posts though. I need to update the front matter for them all :sob:

Yeah, that sucks! Automation in one way or another is probably your friend there. Scripting, if you’re comfortable with that, or the search-and-replace-in-directory feature of your favorite text editor.

If you’re going the scripting route, my blog post How ChatGPT made my migration from Jekyll to Hugo a breeze might be worth a read.

Seems that Micro.Blog doesn’t like it when the front matter on the import contains either;

Category or Tags

The import just fails. I thought maybe it was because the category didn’t exist, but I created it and it made no difference. I have emailed Help@ to see if @manton can assist, I don’t really want to have to remove all the categories then re-add them if I can help it.

I exported my existing Micro.Blog and the categories are referenced exactly the same in my Frontmatter so I suspect the issue is the importer not Hugo.

Micro.blog I think only supports categories, not also tags. So my guess is you’d want to convert all tags to categories if you wanted to maintain all that metadata.

I’d also note that all Micro.blog posts use the layout post, so I’d check for anything without that layout and possibly remove that as well (just for good measure).

Definitely editable in bulk via automation with things like sed or other tooling, but not sure how accessible that is for you.

I tried it with just categories and it still wouldn’t work…the only way I could get it to work was with this front matter

---
title: 'How I Got Here & Where I am Going'
date: 2018-08-28T17:55:31+01:00
layout: post
---

Did some poking around, and it turns out Micro.blog’s import function isn’t using a proper YAML parser. Instead, it expects a comma separated string of categories. Like this:

---
title: 'How I Got Here & Where I am Going'
date: 2018-08-28T17:55:31+01:00
layout: post
categories: sqlserver, another category
---

Providing just one category works as well.

We should probably fix this, @manton, or at least document the behavior.

Oh hang on my front matter looks like this

categories:
- sqlserver

I need to change them all to

categories: sqlserver, second, third, fourth

Now it works.

I have updated the FrontMatter and the import is now underway. Sorry for the hassle on this one.

Edit: All my posts are in along with the images. Thanks for all your help, I really appreciate it.

1 Like

I think the reason why we don’t use a “real” YAML parser is because we try to support some text files from blogging platforms that don’t strictly use YAML. Maybe if there’s no easy fix for this we can at least warn that it’s broken. Sorry for the trouble!

I tried importing an existing Hugo blog via the pile of markdown method, and get an “invalid date” error. I have my front matter set as TOML, like so:

+++
title = "Note on Feb 24 EDT 2010 at 19:0"
publishdate = 2010-02-25
layout = 'post'
+++

Is that allowed, or should I convert it all to YAML?

The Markdown import only supports a subset of YAML, so you have to convert your TOML frontmatter to YAML.

1 Like

Ah ha, thank you!

Also note that the field name should be “date”, not “publishdate”.