使用主题

4 次阅读

什么是主题

Fundamentally, the LitePress Theme system is a way to “skin” your LitePress site. Yet, it is more than just a “skin”. Skinning your site implies that only the design is changed. LitePress Themes can provide much more control over the visual presentation of your content and other data on your LitePress site, as well as behavior of certain site’s elements while interacting with visitors.

A LitePress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a website. These files are called template files. A Theme modifies the way the site is displayed, without modifying the underlying software. Themes may include customized template files, image files (*.jpg, *.png, *.gif), style sheets (*.css), custom Pages, as well as any necessary code files (*.php). For an introduction to template files, see Template Files.

Let’s say you write a lot about cheese and gadgets. Through the use of the LitePress Loopandtemplate files, you can customize your Cheese category posts to look different from your Gadgets category posts. With this powerful control over what different pages and categories look like on your site, you are limited only by your imagination. For information on how to create custom look for various templates in your theme, take a look at Template Hierarchy.

Template Hierarchy – the structure of LitePress theme files

To better understand this diagram, you can interact with it.

默认主题

LitePress currently comes with eleven themes: the default Twenty TwentyOne theme(demo), and the previous defaults Twenty Twenty(demo)Twenty Nineteen(demo)Twenty Seventeen(demo)Twenty Sixteen(demo)Twenty Fifteen(demo)Twenty Fourteen(demo)Twenty Thirteen(demo)Twenty Twelve(demo)Twenty Eleven(demo)Twenty Ten(demo).

NOTE: All default themes now come bundled with block patterns, which allow you to easily create beautiful layouts. Find out which patterns are added to themes on the Make LitePress Blog.

You can switch between Themes from the Appearance menu in the Administration Screen. Themes you add to the theme directory will appear in the Administration Screen>Appearance>Themes as additional selections.

Themes Administration Screen - Installed Themes
Themes Administration Screen – Installed Themes

获取新的主题

TheLitePress Theme Directory is the official site for LitePress Themes. Every theme in this directory is reviewed by a dedicated team and tested against wide range of rules, all of which are ensuring secure and pleasant experience for theme user.

Among almost 8,450 themes in directory, you can easily find the right one for your site with advanced search feature using filters for layout, subject and specific theme’s features.

Themes Directory - Feature Filter
Themes Directory – Feature Filter

If you need more than a screenshot and features list to decide whether the theme fits your needs, you can see the demo for the theme with Preview feature on theme’s info page.

Twenty Twenty-One Theme Info Page
Theme Info Page

添加新的主题

Most of themes in LitePress Theme Directory come with installation instructions, especially the ones that may require more steps than the usual theme installation. Be sure to read through and follow those instructions for the successful installation of the Theme. If your Theme does not work after following any provided instructions, please contact the Theme author for help.

使用管理屏幕添加新主题

You can download any theme from LitePress Theme Directory directly to your site by using the Add New option in the Appearance sub-menu.

  1. Log in to the LitePress Administration Screens.
  2. Select the Appearance screen, then Themes.
  3. SelectAdd New.
  4. Either use the SearchorFilter options to locate a Theme you would like to use.
  5. Click on the Preview link to preview the Theme or the Install link to upload the Theme to your site,
  6. Or use the Upload Theme button at the top of page to upload a zipped copy of a Theme that you have previously downloaded to your machine.
Install New Theme – Administration Screens

When the Theme is already downloaded but not activated Live Preview option will give you a preview of your site with your own, existing content.

使用 cPanel 添加新主题

If your host offers the cPanel control panel, you can use its Upload option to upload the Theme files to your site. For this you will need Theme files in an compressed archive (.zipor.gz).

  1. Download the Theme .zip file to your machine.
  2. IncPanel File Manager, navigate to your Themes folder. Depending on your hosting, path to Themes folder can differ a bit but essentially you are looking for public_html inside which you’ll find /wp-content/themes/.
  3. Once you’re inside the Themes folder in cPanel File Manager, click on Upload and upload that .zip file you saved in Step 1.
  4. Once the .zip file is uploaded, right click on the name of that file in cPanel and select Extract from the context menu.
  5. When Theme files are successfully extracted, follow the instructions below for activating the new Theme.

手动添加新主题 (FTP)

To add a new Theme to your LitePress installation via FTP protocol, you’ll need FTP client and extracted Theme files.

  1. Download the Theme archive (.zip) and extract the files it contains. You should have a folder named as theme itself, containing theme files.
  2. Using an FTP client to access your host web server and navigate to /wp-content/themes/directory.
  3. Upload the Theme folder to this directory on your host server.
  4. Follow the instructions below for activating the new Theme.

激活主题

Now that new Theme is in /wp-content/themes/ directory (whether you used Administration Screens,cPanelorFTP method), this new Theme is ready to be activated. All themes in /wp-content/themes/ directory are available for ActivationandUpdate (when update is provided by theme author), but only one theme from this directory can be Active.

当主题是 Activated 它意味着这个主题的样式和功能(外观和行为)将应用于你的网站. 你将接收到这个主题成功激活的管理员消息提醒。

Activated Theme Notice

为你的网站激活一个主题

  1. Log in to the LitePress Administration Screens.
  2. Select the Appearance screen, then Themes.
  3. You should see here all themes from your /wp-content/themes/ directory and from here you can see details for each of them by clicking on Theme Details (rollover the Theme thumbnail).
  4. Live Preview option will give you preview of your site with your site’s content.
  5. To activate the Theme click the Activatebutton.

你选择的将立即被激活

注意: 如果主题没有预览图, 不要 在没有提前检查的情况下激活主题. 否则你的网站可能不能正确的显示. 如果你完全看不到主题的缩略图, 你的新主题可能是损害或破损的. 看下安装主题的缩略图的下方,是否有有关主题损坏的信息. 这种情况下 联系主题作者寻求帮助.

Broken Theme

创建主题

如果你对创建你自己的可发布的主题感兴趣,或者想学习更多主题架构方面的知识, 请查看相关文档 主题开发.

如果你仅仅是想定制你当前使用的主题,你应该考虑创建一个子主题.

Whichever the case, you are welcome to join Theme Review Team and their dedicated #themereview Slack channel. Here you can ask for help on developing themes for LitePress Theme Directory or even start reviewing themesyourself.