Introduction
This theme has removed support for the built-in APlayer / Meting music player. If you previously injected a player into your site via the theme (e.g., music page, in-article player, floating player), these players will no longer be automatically loaded by the theme after updating.
This article explains:
- What was affected by the removal
- How to use alternative methods if you still want to keep using it
- How to completely clean up leftover resources if you no longer need it
1. What Was Removed
The following code was removed at the theme level (if your site does not use a player at all, you don't need to handle any of this):
themes/butterfly/layout/includes/third-party/aplayer.pug- Previously responsible for loading
APlayerCSS,APlayer.js, andMeting.js, and handling player destroy/re-init on pjax page transitions.
- Previously responsible for loading
themes/butterfly/layout/includes/additional-js.pug- Previously conditionally included the above file based on
aplayer & aplayerInject, now removed.
- Previously conditionally included the above file based on
themes/butterfly/source/css/_layout/third-party.stylanddarkmode.styl.aplayerlayout styles and dark mode adjustments.
themes/butterfly/scripts/common/default_config.jsaplayerInjectdefault configuration.
themes/butterfly/plugins.ymlaplayer_css,aplayer_js,meting_jsCDN resource declarations.
Summary of impact:
- The front-matter variable
aplayer: trueis now ineffective. - The
aplayerInjectconfig (site-wide injection) is now ineffective. <div class="aplayer" ...>in articles or pages will not display the player unless you import the resources yourself (it will show a blank or unchanged div).
2. I Want to Keep Using It β What Should I Do?
The theme no longer loads the player for you, but you can simply import the resources yourself. Below is an alternative approach.
Site-wide Injection via inject (Simplest)
Add the following to the inject section in _config.butterfly.yml:
1 | inject: |
Note: The inject keys in this theme are
head/bottom(inserted before</head>and</body>respectively).
Then add the player HTML on the desired page:
1 | <div class="aplayer" data-id="60198" data-server="netease" data-type="playlist" data-autoplay="true" muted></div> |
If you have pjax enabled, the player may not automatically re-initialize when switching pages. Add the following script to the bottom inject:
1 | <script> |
Adding Back the .aplayer Styles
The theme also removed the .aplayer layout styles. If you want the player to look the same as before, add the following <style> to the head inject (includes appearance fixes for the playlist when beautify.enable is turned on):
1 | <style> |
If you use dark mode, you can also add the original dark mode adjustment:
1 | .aplayer { |
These styles are optional β they only make the player appearance more consistent with the original theme. Not adding them won't affect player functionality.
Advanced approach: You can also install the
hexo-tag-aplayertag plugin to embed players via tag plugins, which is easier to maintain than modifying theme files directly.
3. No Longer Needed β How to Clean Up Completely?
If you decide to stop using the player, check and clean up the following:
- Config removal:
_config.butterfly.yml- Remove the
aplayerInjectsection (if it exists). - Remove any APlayer / Meting
<link>/<script>you added toinject. - If you had a
Music: /music/navigation item, remove it as well.
- Remove the
- Pages and articles:
- Delete the music page (
source/music/). - Search for
<div class="aplayer"...>,aplayer:,meting:in all articles and remove them.
- Delete the music page (
- Use the checklist from Section 1 to confirm no leftovers remain, and clean them up one by one.
4. Post-Update Self-Check
If you find that "the player was there before but now it's gone" after updating the theme, check the following in order:
- Does
_config.butterfly.yml(and the theme_config.yml) still containaplayerInject/Musicmenu? - Do articles and pages still have
<div class="aplayer">tags? - Have you added APlayer and Meting resources yourself via
inject(or HEAD/BODY)? - If pjax is enabled, is
loadMeting()being re-called onpjax:complete?
After completing these steps, the player should work normally and match your desired configuration.
