Code Monkey home page Code Monkey logo

hexo-google-adsense's Introduction

Hexo 的谷歌广告插件

用途说明

支持使用 Hexo 自定义标签将谷歌广告代码动态插入到指定的文章的特定位置中,广告类型一般是谷歌的文章内嵌广告,但也支持谷歌其他类型的广告。

使用步骤

  1. 安装插件:npm install hexo-google-adsense --save
  2. 编辑 Hexo 的 _config.yml 配置文件,添加对应的插件配置信息
  3. 在本地或网络上创建存放谷歌广告代码的文件,并拷贝谷歌的广告代码到文件中
  4. 编辑 Hexo 的 MarkDown 文件,在希望添加谷歌广告的地方,增加右边这行内容即可: {% GoogleAdsense %}

提示: {% GoogleAdsense %} 中的 GoogleAdsense 是 Hexo 自定义标签默认的名称

配置示例

hexo_google_adsense:
  enable: true
  log_msg: true
  tag_name: 'GoogleAdsense'
  file_path: 'source/ads/google/article_ads.html'

参数说明

  • enable: 是否启用插件,默认值为: false
  • log_msg: 是否打印日志信息,默认值为: false
  • tag_name: Hexo 自定义标签的名称,默认值为: GoogleAdsense
  • file_path: 谷歌广告代码文件的路径,支持使用绝对路径或者相对于 Hexo 博客根目录的路径(例如: source/ads/google/article_ads.html),同时支持使用 URL 路径(例如: https://www.example.com/ads/google/article_ads.html

注意事项

根据谷歌官方的要求,使用此插件时必须在 Hexo 主题的模板文件中的 Head 标签内添加如下的一行代码(请自行替换掉 xxxx):

<head>
  <script data-ad-client="xxxx" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>

待优化功能

目前只支持在 Hexo 的 _config.yml 文件中配置单一类型的谷歌广告,后续考虑结合 Hexo 自定义标签的参数,支持在不同的文章中插入不同类型的广告。

hexo-google-adsense's People

Contributors

rqh656418510 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.