Quick Start
According to the official document of NexT
, we can implement the customization of NexT
by theme_inject
. This blog will talk about how to customize your NexT
with the config and create your own inject step by step as well.
Using Injects
custom_file_path
First, uncomment the code in the themes/next/_config.yml
( If you are using the submodule and CI tool metioned in the previous blog, please remember to change the deploy/_config.yml
as well). NexT
has already created the 10 injection points as following. Of cause, you can change the path here to your own customized path.
1 | custom_file_path: |
Then, create the file with the path set in the config file and add your own code there.
Insert Your Own Injecttion
First, create a new js
file under the scripts
folder. All the js
files will be excuted when Hexo
server has been started.
scripts/gitter.js
1 | hexo.extend.filter.register('theme_inject', function(injects) { |
Then create the view file with the path above:
views/gitter.swig
1 | <script> |
Start the server, now you can see the gitter
right bottom. In addition, you can also inject the style of gitter
as well.
scripts/gitter.js
1 | hexo.extend.filter.register('theme_inject', function(injects) { |
styles/gitter.styl
1 | .gitter-open-chat-button { |
Example: Add Google Adsense in Your Blog
I recommend to use the automatic adv of Google Adsense
. It has no need to think about where to put the advertisement and easier to import. Just one line in source/_data/header.swig
.
1 | <script data-ad-client="{CLIENT-ID}" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> |
Example: Customize the Header Image of Your Blog
NexT
is a Minimalism theme. That’s why we choose it. Since it has been more and more popular, sometimes we’d like to change something in our blog to make it look a little different with others.
I have added the header image and changed the style of web title and menus. In addition, to avoid the footer being overlapped with the Addthis
plugin on mobile, I expanded the padding-bottom
of footer
.
1 | .header { |