Saturday 29 July 2023

WordPress から Hugo への移行のまとめ

WordPressのDBから *.md を拾ってくるのが正解な気もするけど、*.html から、直接 *.md 生成する方針で

で、theme も元の WordPress のを、そのままコピる。

*.md はPerl で find file しながら適当に。変換するファイルを list.txt に入れておく方式です。

ファイルの日付は、*.html に合わせて、それを保存します。

https://github.com/ie-developers/wp-to-md

これで、*/_index.md などができるので、これを content に入れて、hugo を設定すれば良い。

この時に、
  content/ja content/en

とすると多言語対応が可能。

なのだが、元の WordPress の html file から、css / js を抜き出して、そのまま hugo theme にしまし√た。

抜き出した css / js は static の下。前後を header.html / footer.html で抜き出して layouts/partials に置く。
    ie-hugo-theme
    ├── LICENSE
    ├── README.md
    ├── archetypes
    │   └── default.md
    ├── layouts
    │   ├── 404.html
    │   ├── _default
    │   │   ├── baseof.html
    │   │   ├── list.html
    │   │   ├── section.html
    │   │   ├── single.html
    │   │   ├── staff.html
    │   │   └── top.html
    │   └── partials
    │       ├── footer.html
    │       ├── header.html
    │       ├── ie-jquery.html
    │       └── top-jquery.html
    ├── static
    │   ├── before.css
    │   ├── profile.css
    │   └── top.css
    └── theme.toml




https://github.com/ie-developers/ie-hugo-theme.git

config.toml は以下のような感じです (hugo v0.112.0)
    hasCJKLanguage = true
    baseurl = "https://ie.u-ryukyu.ac.jp/"  # Include trailing slash
    title = "home"
    copyright = "Copyright © 2021-2023"
    # canonifyurls = true
    paginate = 10
    theme = "ie-hugo-theme"
    drafts = false
    enableRobotsTXT = true
    [languages]
      [languages.en]
        title = "Your Website Title in English"
        languageName = "English"
        contentDir = "content/en"
        weight = 1
      [languages.ja]
        title = "Your Website Title in Japanese"
        languageName = "日本語"
        contentDir = "content/ja"
    [params]
      description = "This is a multilingual Hugo site"
      author = "Author Name"
    [[menu.main]]
        identifier = "home"
        name = "Home"
        url = "/"
        weight = 10
    [[menu.main]]
        identifier = "hugo"
        name = "Hugo"
        url = "/"
        weight = 20
    [permalinks]
        section = "/:sections/:title/"
    [frontmatter]
       date                       = [ "date", ":filename", ":default"]
       publishDate                = [ "publishDate", "date"]
       lastmod                    = [ "lastmod", ":fileModTime", "publishDate"]
       expiryDate                 = [ "expiryDate"]

No comments: