Add schema.org microdata to your markup super easy
npm install posthtml-schemas[![NPM Version][npm-img]][npm] [![Build Status][ci-img]][ci]
[Schemas] makes it super easy to write [schema.org] microdata without extra cruft. Search engine operators like Google, Microsoft and Yahoo! will rely on this markup to improve search results.
`` html
ACME Executive Anvil

Average rating: 4.4, based on
89 reviews
from $119.99 to
$199.99

Average rating: 4.4, based on
89 reviews
from $119.99 to
$199.99
Features
Schemas makes the
itemscope property totally optional. This is because the [microdata spec] says itemtype must not be specified on elements that do not also have an itemscope attribute.Schemas makes the
http://schema.org/ prefix totally optional. This is because all major search engines now [recognize] this common data vocabulary.Usage
Add [Schemas] to your build tool:
`bash
npm install posthtml-schemas --save-dev
`#### Node
`js
require('posthtml-schemas').process(YOUR_HTML, { / options / });
`#### PostHTML
Add [PostHTML] to your build tool:
`bash
npm install posthtml --save-dev
`Load [Schemas] as a PostHTML plugin:
`js
posthtml([
require('posthtml-schemas')({ / options / })
]).process(YOUR_HTML, / options /);
`#### Gulp
Add [Gulp PostHTML] to your build tool:
`bash
npm install gulp-posthtml --save-dev
`Enable [Schemas] within your Gulpfile:
`js
var posthtml = require('gulp-posthtml');gulp.task('html', function () {
return gulp.src('./src/*.html').pipe(
posthtml([
require('posthtml-schemas')({ / options / })
])
).pipe(
gulp.dest('.')
);
});
`#### Grunt
Add [Grunt PostHTML] to your build tool:
`bash
npm install grunt-posthtml --save-dev
`Enable [Schemas] within your Gruntfile:
`js
grunt.loadNpmTasks('grunt-posthtml');grunt.initConfig({
posthtml: {
options: {
use: [
require('posthtml-schemas')({ / options / })
]
},
dist: {
src: '*.html'
}
}
});
`Options
####
urlType:
Object|String
Default: "http://schema.org/"Specifies the URL used to prefix your microdata vocabulary (
itemtype`). You may also pass in an object of individual URLs for each vocabulary.[ci]: https://travis-ci.org/jonathantneal/posthtml-schemas
[ci-img]: https://img.shields.io/travis/jonathantneal/posthtml-schemas.svg
[npm]: https://www.npmjs.com/package/posthtml-schemas
[npm-img]: https://img.shields.io/npm/v/posthtml-schemas.svg
[schema.org]: https://schema.org/
[microdata spec]: https://html.spec.whatwg.org/multipage/microdata.html#items
[recognize]: http://schema.org/docs/schemas.html
[Gulp PostHTML]: https://github.com/posthtml/gulp-posthtml
[Grunt PostHTML]: https://github.com/TCotton/grunt-posthtml
[PostHTML]: https://github.com/posthtml/posthtml
[Schemas]: https://github.com/jonathantneal/posthtml-schemas