Title: Theme YAML &#8211; Use YAML instead JSON for your theme.json settings and styles
Author: landwire
Published: <strong>2022 年 3 月 17 日</strong>
Last modified: 2023 年 9 月 22 日

---

搜索插件

![](https://ps.w.org/theme-yaml/assets/banner-772-250.png?rev=2695658)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/theme-yaml/assets/icon.svg?rev=2695658)

# Theme YAML – Use YAML instead JSON for your theme.json settings and styles

 作者：[landwire](https://profiles.wordpress.org/landwire/)

[下载](https://downloads.wordpress.org/plugin/theme-yaml.1.3.0.zip)

 * [详情](https://cn.wordpress.org/plugins/theme-yaml/#description)
 * [评价](https://cn.wordpress.org/plugins/theme-yaml/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/theme-yaml/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/theme-yaml/#developers)

 [支持](https://wordpress.org/support/plugin/theme-yaml/)

## 描述

Theme Yaml converts your theme.yaml file into theme.json so that you can configure
your theme with YAML. It has the benefit of being able to add comments and is more
concise than JSON. The generated theme.json is left as a one liner by default, so
that you can see it is generated. This however can be changed through the ‘theme_yaml_json_pretty_print’
filter.

The plugin automatically looks for a theme.yaml file in the active theme’s root 
folder when a page is loaded. If found, it will check its last modified time and
store the value in the database. If there are new modifications, the plugin parses
theme.yaml, converts it to JSON, and writes it to the theme.json file.

If the active theme is a child, it will also automatically run through this process
for its parent.

### Configuration

Add a theme.yaml file with your theme settings in your theme’s root directory. If
you already have an existing theme.json file, you can convert it to the YAML format
using an online tool. I personally use https://www.json2yaml.com/. The plugin will
then convert the theme.yaml file into JSON and save it to the theme.json file.

## 安装

 1. Upload `theme-yaml` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## 常见问题

### How does the plugin work?

The plugin automatically looks for a theme.yaml file in the active theme’s root 
folder when a page is loaded. If found, it will check its last modified time and
store the value in the database. If there are new modifications, the plugin parses
theme.yaml, converts it to JSON, and writes it to the theme.json file.

### Does it work for child as well as for parent themes?

If the active theme is a child, it will also automatically run through this process
for its parent and the child.

### Is there a way to pretty print the JSON file?

I left the generated theme.json file intentionally a one liner, so everybody can
see it is generated. But if you would like to change this you can use the following
filter to make the JSON file more readable:
 ` function pretty_print_json() { return
true; }

add_filter(‘theme_yaml_json_pretty_print’, ‘pretty_print_json’);
 `

## 评价

![](https://secure.gravatar.com/avatar/16f83f29fa0e18e6804e389caf30e4b0da19de46ecb570873571191071fa6fa6?
s=60&d=retro&r=g)

### 󠀁[Very useful tool](https://wordpress.org/support/topic/very-useful-tool-104/)󠁿

 [Gyurmey](https://profiles.wordpress.org/gyurmey/) 2023 年 2 月 13 日 1 回复

Works really well!

![](https://secure.gravatar.com/avatar/127b0146d524b574fb7bc06e8fa0a31cf4216076e2d8171725e946f299572150?
s=60&d=retro&r=g)

### 󠀁[Really useful!](https://wordpress.org/support/topic/really-useful-263/)󠁿

 [Jakob Wiens](https://profiles.wordpress.org/jakobwiens/) 2022 年 4 月 6 日 1 回复

This plugin comes in pretty handy when developing block themes – since handling 
an ever-growing theme.json file really sucks and you can’t even use basic features
like comments, etc. But no more, with “Theme YAML” i can finally write and maintain
readable global styles and theme settings without a hassle 🙂 Very easy to use, 
there are no settings: Just install, activate and you’re basically good to go!

 [ 阅读所有2条评价 ](https://wordpress.org/support/plugin/theme-yaml/reviews/)

## 贡献者及开发者

「Theme YAML – Use YAML instead JSON for your theme.json settings and styles」是
开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ landwire ](https://profiles.wordpress.org/landwire/)

「Theme YAML – Use YAML instead JSON for your theme.json settings and styles」插
件已被翻译至 1 种本地化语言。 感谢[所有译者](https://translate.wordpress.org/projects/wp-plugins/theme-yaml/contributors)
为本插件所做的贡献。

[帮助将「Theme YAML – Use YAML instead JSON for your theme.json settings and styles」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/theme-yaml)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/theme-yaml/)，查看[SVN仓库](https://plugins.svn.wordpress.org/theme-yaml/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/theme-yaml/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/theme-yaml/)。

## 更新日志

#### 1.3.0

Updated composer packages

#### 1.2.0

Added backup for theme.json

#### 1.1.1

Fixed readme formatting

#### 1.1.0

Changed settings to output the theme.json file in a more readable way. Also added
a filter to change the JSON encoding flags. Kindly suggested by Justin Tadlock in
his review of this plugin here: https://wptavern .com/new-plugin-for-writing-wordpress-
theme-json-files-via-yaml

#### 1.0.0

 * Initial Release of the plugin

## 额外信息

 *  版本 **1.3.0**
 *  最后更新：**3 年前**
 *  活跃安装数量 **10+**
 *  WordPress 版本 ** 5.8 或更高版本 **
 *  已测试的最高版本为 **6.3.8**
 *  PHP 版本 ** 7.4 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/theme-yaml/) 和 [Italian](https://it.wordpress.org/plugins/theme-yaml/).
 *  [翻译成简体中文](https://translate.wordpress.org/projects/wp-plugins/theme-yaml)
 * 标签
 * [settings](https://cn.wordpress.org/plugins/tags/settings/)[styles](https://cn.wordpress.org/plugins/tags/styles/)
   [theme](https://cn.wordpress.org/plugins/tags/theme/)[theme.json](https://cn.wordpress.org/plugins/tags/theme-json/)
   [yaml](https://cn.wordpress.org/plugins/tags/yaml/)
 *  [高级视图](https://cn.wordpress.org/plugins/theme-yaml/advanced/)

## 评级

 4.5 星（最高 5 星）。

 *  [  1 条 5 星评价     ](https://wordpress.org/support/plugin/theme-yaml/reviews/?filter=5)
 *  [  1 条 4 星评价     ](https://wordpress.org/support/plugin/theme-yaml/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/theme-yaml/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/theme-yaml/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/theme-yaml/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/theme-yaml/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/theme-yaml/reviews/)

## 贡献者

 *   [ landwire ](https://profiles.wordpress.org/landwire/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/theme-yaml/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://saschapaukner.de)