Compare commits

...

438 Commits

Author SHA1 Message Date
jekyllbot f449b1af64 Update history to reflect merge of #492 [ci skip] 2023-11-06 09:20:39 -08:00
Pierre de La Morinerie 589feb0186
Truncate the description value to 100 words (#492)
Merge pull request 492
2023-11-06 09:20:37 -08:00
Ashwin Maroli db0e639259
Stop profiling memory when Jekyll 3.x 2023-02-01 22:59:22 +05:30
Ashwin Maroli c90dcf86d8
[style] Add empty line after guard clause 2023-01-30 17:10:01 +05:30
jekyllbot 6005f93781 Update history to reflect merge of #466 [ci skip] 2022-09-04 07:19:46 -07:00
Scott Perry 1980476395
Support for image paths relative to the page's directory (#466)
Merge pull request 466
2022-09-04 07:19:44 -07:00
jekyllbot 7d1d478c0b Update history to reflect merge of #464 [ci skip] 2022-07-13 16:47:30 -07:00
Amir Masoud Abdol 799da8f3bf
Added the `twitter:description` tag (#464)
Merge pull request 464
2022-07-13 16:47:29 -07:00
jekyllbot 62d7e8af8b Update history to reflect merge of #462 [ci skip] 2022-04-28 05:06:48 -07:00
Baoshuo Ren 5200f23221
chore: remove git.io (#462)
Merge pull request 462
2022-04-28 05:06:46 -07:00
jekyllbot 9e452bf1d6 Update history to reflect merge of #459 [ci skip] 2022-02-04 12:41:53 -05:00
Peter Goldstein b41ebd39a8
Add Ruby 3.1 to CI matrix (#459)
Merge pull request 459
2022-02-04 12:41:52 -05:00
Ashwin Maroli 792a0fa3ab Release 💎 v2.8.0 2022-02-04 22:17:28 +05:30
jekyllbot 7209c422e5 Update history to reflect merge of #458 [ci skip] 2022-02-04 11:17:54 -05:00
Parker Moore 54d37a8396
Sort JSON-LD data by key (#458)
Merge pull request 458
2022-02-04 11:17:52 -05:00
Ashwin Maroli 8303d31d79
Add workflow to release gem via GH Actions 2022-02-04 12:27:51 +05:30
Ashwin Maroli c658a8dd9d
Reduce verbosity of workflow job names 2021-11-26 20:35:50 +05:30
jekyllbot 4037708eff Update history to reflect merge of #454 [ci skip] 2021-11-22 13:24:32 -05:00
Tobias e19993b3e0
Template: Remove double new line (#454)
Merge pull request 454
2021-11-22 13:24:30 -05:00
jekyllbot dba6621d1f Update history to reflect merge of #438 [ci skip] 2021-11-22 12:56:59 -05:00
Tobias 4a590c9d0b
Add `og:image:alt` and `twitter:image:alt` (#438)
Merge pull request 438
2021-11-22 12:56:57 -05:00
jekyllbot 41b23937a9 Update history to reflect merge of #455 [ci skip] 2021-10-28 12:59:08 -04:00
fauno 062604e7e1
Implement Facebook domain verification (#455)
Merge pull request 455
2021-10-28 12:59:07 -04:00
jekyllbot 36330e876c Update history to reflect merge of #391 [ci skip] 2021-10-08 06:05:06 -04:00
Igor Żuk f1b98288e3
Set the default og:type to 'website' (#391)
Merge pull request 391
2021-10-08 06:05:05 -04:00
jekyllbot dff018c347 Update history to reflect merge of #453 [ci skip] 2021-10-08 01:50:07 -04:00
Ilgiz Mustafin 8b5d2901c2
Allow setting `author.url` (#453)
Merge pull request 453
2021-10-08 01:50:06 -04:00
Ashwin Maroli be9ce5d13e Profile using an intermediate shell script 2021-10-07 23:18:54 +05:30
Ashwin Maroli b5c53de8f0
Profile with multiple Jekyll versions 2021-10-07 22:53:32 +05:30
jekyllbot 7c0d75a29b Update history to reflect merge of #452 [ci skip] 2021-09-17 10:19:58 -04:00
Ashwin Maroli 6c387eaeb4
Bump RuboCop to v1.18.x (#452)
Merge pull request 452
2021-09-17 10:19:57 -04:00
Ashwin Maroli e1a60e2fdf
Update third-party repo profile workflow config
* Set ruby_version via `strategy.matrix`.
  * Migrate to `ruby/setup-ruby` action.
  * Use double-quoted strings consistently.
2021-09-17 12:54:01 +05:30
jekyllbot 7b5478a249 Update history to reflect merge of #450 [ci skip] 2021-09-01 10:47:51 -04:00
Ashwin Maroli e3d0542ce6
Set up Continuous Integration via GH Actions (#450)
Merge pull request 450
2021-09-01 10:47:50 -04:00
jekyllbot 01fcf38c8b Update history to reflect merge of #449 [ci skip] 2021-09-01 08:46:00 -04:00
Michael Currin d055720b4e
docs: fix typo (#449)
Merge pull request 449
2021-09-01 08:45:59 -04:00
jekyllbot 93c664bce0 Update history to reflect merge of #427 [ci skip] 2021-01-11 11:13:52 -05:00
Elias Fröhner 9cb1ad0bd6
Allow to set type for author (#427)
Merge pull request 427
2021-01-11 11:13:50 -05:00
Ashwin Maroli 22a160cb32
Remove redundant escapes inside regexp literal 2020-10-26 12:15:58 +05:30
Frank Taillandier df294bb491 chore(release): v.2.7.1 💎 2020-10-18 10:38:33 +02:00
jekyllbot a7e1b5d8ec Update history to reflect merge of #419 [ci skip] 2020-10-18 04:36:57 -04:00
Ashwin Maroli a1e0cdd25f
Mutate site payload instead of duplicating it (#419)
Merge pull request 419
2020-10-18 04:36:55 -04:00
Frank Taillandier 20d61fa728 chore(release): 2.7.0 2020-10-18 10:24:32 +02:00
Frank Taillandier 8d509f2616 chore(deps): Ruby > 2.4 EOL 2020-10-18 10:13:10 +02:00
jekyllbot 6f30b00845 Update history to reflect merge of #418 [ci skip] 2020-10-15 09:59:50 -04:00
Ashwin Maroli 80da6a7da9
Replace read-only empty hash with private constant (#418)
Merge pull request 418
2020-10-15 09:59:48 -04:00
jekyllbot d77ffc4de5 Update history to reflect merge of #343 [ci skip] 2020-10-08 11:13:38 -04:00
Ashwin Maroli e1ff8ee6e8
Simplify conditional in SeoTag::Drop#date_modified (#343)
Merge pull request 343
2020-10-08 11:13:37 -04:00
jekyllbot 442133d898 Update history to reflect merge of #388 [ci skip] 2020-10-08 10:42:02 -04:00
Ashwin Maroli 54beeaaaf6
Render og:locale meta only when defined explicitly (#388)
Merge pull request 388
2020-10-08 10:42:00 -04:00
jekyllbot dac459f6f9 Update history to reflect merge of #417 [ci skip] 2020-10-07 11:51:34 -04:00
Ashwin Maroli 76e062d734
Mutate hash literals instead of duplicating them (#417)
Merge pull request 417
2020-10-07 11:51:32 -04:00
jekyllbot ae0f02f1e0 Update history to reflect merge of #414 [ci skip] 2020-09-30 05:37:36 -04:00
Ashwin Maroli c00f3dbc26
Profile plugin using a third-party repo (#414)
Merge pull request 414
2020-09-30 05:37:34 -04:00
jekyllbot ae6ce57b36 Update history to reflect merge of #415 [ci skip] 2020-09-21 11:39:45 -04:00
Ashwin Maroli 6906e8792e
Fix Travis builds for Jekyll 3.x (#415)
Merge pull request 415
2020-09-21 11:39:43 -04:00
jekyllbot 933b914ab2 Update history to reflect merge of #409 [ci skip] 2020-07-24 14:34:18 -04:00
Joe Masilotti 0b5f02ab6c
Structured Data Testing Tool is deprecated (#409)
Merge pull request 409
2020-07-24 14:34:17 -04:00
jekyllbot 8dc3a01b39 Update history to reflect merge of #399 [ci skip] 2020-06-28 10:43:00 -04:00
Ashwin Maroli 12c2c8eb64
Improve documentation on plugin usage (#399)
Merge pull request 399
2020-06-28 10:42:57 -04:00
jekyllbot fa6ca2891c Update history to reflect merge of #403 [ci skip] 2020-06-16 12:46:26 -04:00
Pavel Timofeev 4f38339782
Rename Google webmaster tools to Google Search Console and fix a few small issues (#403)
Merge pull request 403
2020-06-16 12:46:24 -04:00
jekyllbot 6135021410 Update history to reflect merge of #376 [ci skip] 2020-04-13 11:42:32 -04:00
Ashwin Maroli b019d441b9
Reduce allocations of instance-agnostic objects (#376)
Merge pull request 376
2020-04-13 11:42:30 -04:00
jekyllbot 47e874a116 Update history to reflect merge of #385 [ci skip] 2020-04-13 07:15:39 -04:00
Frank Taillandier cdbc366129
chore(ci): bump Ruby versions (#385)
Merge pull request 385
2020-04-13 07:15:37 -04:00
jekyllbot 38ef0bea22 Update history to reflect merge of #382 [ci skip] 2020-03-20 06:55:34 -04:00
Frank Taillandier e22311ec1a
style: align with latest jekyll-rubocop (#382)
Merge pull request 382
2020-03-20 06:55:32 -04:00
Frank Taillandier 76fd24544c
Merge pull request #380 from jekyll/require_version
chore(dev): simplify require for version
2020-03-16 09:19:17 +01:00
Frank Taillandier fc51dbdf86
chore(dev): simplify require for version 2020-03-15 23:57:38 +01:00
jekyllbot 0f24641c5e Update history to reflect merge of #360 [ci skip] 2020-01-31 04:39:41 -05:00
Liam Cooke 6f35c9c05b
Fix locale specs that use the fallback locale (#360)
Merge pull request 360
2020-01-31 04:39:38 -05:00
jekyllbot 2d058584e4 Update history to reflect merge of #372 [ci skip] 2019-12-04 08:01:32 -05:00
Frank Taillandier d8a80bfba4 chore(ci): test Jekyll v4.0 (#372)
Merge pull request 372
2019-12-04 08:01:30 -05:00
jekyllbot 68361c37ed Update history to reflect merge of #342 [ci skip] 2019-11-29 09:06:05 -05:00
Ashwin Maroli 895ab6c45b Memoize #author_hash in SeoTag::AuthorDrop (#342)
Merge pull request 342
2019-11-29 09:06:03 -05:00
jekyllbot 3b99176f14 Update history to reflect merge of #356 [ci skip] 2019-11-29 08:18:16 -05:00
Florian Klampfer 331903536d Prefer site.tagline to site.description for page title (#356)
Merge pull request 356
2019-11-29 08:18:14 -05:00
Frank Taillandier 40ef3ae227
Merge pull request #371 from coliff/patch-1
Update homepage
2019-11-29 09:58:55 +01:00
Christian Oliff ba0810c829
Update jekyll-seo-tag.gemspec
update homepage link to: https://github.com/jekyll/jekyll-seo-tag
2019-11-29 13:15:20 +09:00
jekyllbot 0943563d0a Update history to reflect merge of #367 [ci skip] 2019-11-13 15:32:33 -05:00
Martin Stühmer 16a5e3d6b0 Ensure a single leading `@` for twitter usernames (#367)
Merge pull request 367
2019-11-13 15:32:31 -05:00
jekyllbot a937289d05 Update history to reflect merge of #284 [ci skip] 2019-10-30 12:00:04 -04:00
Wei-Chung Liao 39442c20c6 Make Twitter card without having Twitter account (#284)
Merge pull request 284
2019-10-30 12:00:00 -04:00
jekyllbot 242ad4f127 Update history to reflect merge of #324 [ci skip] 2019-10-08 10:42:27 -04:00
jekyllbot 32ce8914f4
Merge pull request #324 from AlekseySpiridonov/add-custom-paginator-message
Merge pull request 324
2019-10-08 10:42:25 -04:00
Frank Taillandier 6bb46cc6d7
Merge branch 'master' into add-custom-paginator-message 2019-10-03 18:49:45 +02:00
jekyllbot 4ca8035783 Update history to reflect merge of #359 [ci skip] 2019-09-05 02:42:07 -04:00
Christian Oliff 9befae460b HTTPS link to https://ogp.me/ (#359)
Merge pull request 359
2019-09-05 02:42:06 -04:00
jekyllbot d96bd7761f Update history to reflect merge of #358 [ci skip] 2019-09-05 02:38:16 -04:00
Christian Oliff e457314bfd remove Google+ from example snippet (#358)
Merge pull request 358
2019-09-05 02:38:15 -04:00
Frank Taillandier e007a97175
Merge pull request #352 from coliff/patch-1
Update Google's structured-data docs URL to prevent redirect
2019-05-30 14:40:47 +02:00
Christian Oliff 0661e4d44d
Update Google's structured-data docs URL to prevent redirect 2019-05-30 20:25:09 +09:00
jekyllbot 2def9a6d23 Update history to reflect merge of #351 [ci skip] 2019-05-30 07:23:34 -04:00
Christian Oliff 10c1802175 use example.com for example URL (#351)
Merge pull request 351
2019-05-30 07:23:32 -04:00
jekyllbot aa9a279b8a Update history to reflect merge of #350 [ci skip] 2019-05-30 07:20:37 -04:00
Christian Oliff 664a9ea50c HTTPS links (#350)
Merge pull request 350
2019-05-30 07:20:35 -04:00
Frank Taillandier ec35d6a8c5
Merge pull request #346 from jekyll/pull/release-2.6.1
Release: v2.6.1
2019-05-17 09:11:18 +02:00
Frank Taillandier acc149372d
Update release date 2019-05-17 08:57:36 +02:00
Ashwin Maroli 531b25f971
Use the latest version of Rubygems 2019-05-17 00:23:04 +05:30
Frank Taillandier 68e5ae2981
Release: v2.6.1 2019-05-11 00:54:51 +02:00
jekyllbot 8dfc4133ac Update history to reflect merge of #336 [ci skip] 2019-03-25 07:33:56 -04:00
Ben Balter 23ccab3a68 Test against Jekyll 4.x (#336)
Merge pull request 336
2019-03-25 07:33:55 -04:00
jekyllbot 451b2dca2b Update history to reflect merge of #334 [ci skip] 2019-03-16 04:56:16 -04:00
jekyllbot d2691d96ad
Release 💎 v2.6.0 (#334)
Merge pull request 334
2019-03-16 04:56:15 -04:00
jekyllbot a688cda0ac Update history to reflect merge of #306 [ci skip] 2019-03-16 04:30:13 -04:00
Ashwin Maroli 2f80d62208 Do not cache the drop payload for SeoTag (#306)
Merge pull request 306
2019-03-16 04:30:11 -04:00
jekyllbot ad3f7e3f48 Update history to reflect merge of #333 [ci skip] 2019-03-06 09:57:08 -05:00
jekyllbot 5bb39c54e2
chore (ci): remove deprecated `sudo: false` in .travis.yml (#333)
Merge pull request 333
2019-03-06 09:57:04 -05:00
jekyllbot f66eb193ab Update history to reflect merge of #330 [ci skip] 2019-02-16 10:40:07 -05:00
Scott Watermasysk 7898489736 Twitter Image and Title (#330)
Merge pull request 330
2019-02-16 10:40:06 -05:00
jekyllbot 45c8eb7718 Update history to reflect merge of #328 [ci skip] 2019-01-30 09:32:52 -05:00
Ashwin Maroli 92450f130b Rectify error in Usage documentation (#328)
Merge pull request 328
2019-01-30 09:32:50 -05:00
Ashwin Maroli 8557598116 prefix config key with 'seo_' to avoid conflicts 2019-01-08 20:27:50 +05:30
jekyllbot ded24a0254 Update history to reflect merge of #326 [ci skip] 2019-01-06 14:34:12 -05:00
jekyllbot 37829f05ab
chore(ci): Add Ruby 2.6, drop Ruby 2.3 (#326)
Merge pull request 326
2019-01-06 14:34:11 -05:00
Ashwin Maroli 81b9bf16ba Merge branch 'master' into this branch 2019-01-06 23:54:35 +05:30
jekyllbot 20e50fad29 Update history to reflect merge of #325 [ci skip] 2019-01-06 13:20:50 -05:00
Ashwin Maroli cd82c88532 Relax version constraint on Bundler (#325)
Merge pull request 325
2019-01-06 13:20:49 -05:00
Ashwin Maroli 5aab527805 Improve documentation for this enhancement 2019-01-06 12:05:30 +05:30
Ashwin Maroli 9b1001eb62 undo unnecessary change 2019-01-06 11:50:03 +05:30
Ashwin Maroli d585dc3418 Undo change outside the scope of this pull request 2019-01-06 11:49:21 +05:30
Aleksey Spiridonov 39269edc33 Adding possibility to change pagination message by config file
Default message can by overriten by "paginator_message" parameter in _config.yml
2019-01-06 01:22:28 +04:00
jekyllbot bb04d06a3e Update history to reflect merge of #320 [ci skip] 2018-12-06 06:07:55 -05:00
jekyllbot 31881b5273
chore(deps): 🆙 rubocop-jekyll 0.4 (#320)
Merge pull request 320
2018-12-06 06:07:53 -05:00
jekyllbot a6fab73d5b Update history to reflect merge of #319 [ci skip] 2018-12-06 05:07:43 -05:00
Ashwin Maroli 28cc024648 Correct RuboCop offenses in spec files (#319)
Merge pull request 319
2018-12-06 05:07:41 -05:00
jekyllbot 19fd87e0fe Update history to reflect merge of #316 [ci skip] 2018-10-26 10:49:06 -04:00
jekyllbot 3be2c5eabe
deps: bump rubocop-jekyll to 0.3.0 (#316)
Merge pull request 316
2018-10-26 10:49:04 -04:00
jekyllbot 2184b8b201 Update history to reflect merge of #302 [ci skip] 2018-07-21 20:27:37 -04:00
Ashwin Maroli d8dba4bffa Lint Ruby code with rubocop-jekyll gem (#302)
Merge pull request 302
2018-07-21 20:27:36 -04:00
jekyllbot 7383259267 Update history to reflect merge of #296 [ci skip] 2018-05-23 11:33:09 -04:00
mindl3ss a50f80be47 Update url of schema website (#296)
Merge pull request 296
2018-05-23 11:33:06 -04:00
Ben Balter b363225849
Merge pull request #293 from jekyll/release-2.5.0
Release 💎 2.5.0
2018-05-21 09:51:08 -04:00
Pat Hawks 9e3380f736
Release 💎 2.5.0 2018-05-18 17:17:17 -05:00
jekyllbot b0b7fcf22b Update history to reflect merge of #292 [ci skip] 2018-05-18 16:17:53 -04:00
Frank Taillandier d01bbe7abf Target Ruby 2.3 and Rubocop 0.56.0 (#292)
Merge pull request 292
2018-05-18 16:17:52 -04:00
jekyllbot 1fa8f08989 Update history to reflect merge of #289 [ci skip] 2018-05-12 16:01:47 -04:00
Tsukasa Setoguchi f8800e5286 add tests for twitter.card types (#289)
Merge pull request 289
2018-05-12 16:01:45 -04:00
Frank Taillandier edaa2d582c
Merge pull request #288 from set0gut1/fix-markdown
Fix markdown for a code snippet and some indents
2018-05-11 03:51:46 +02:00
Tsukasa Setoguchi 6806b4ee10 Fix markdown for indents 2018-05-11 10:27:40 +09:00
Tsukasa Setoguchi e054e4e7ad Fix markdown for a code snippet 2018-05-11 10:26:35 +09:00
jekyllbot 4617e87179 Update history to reflect merge of #225 [ci skip] 2018-05-02 20:04:20 -04:00
Chris Blyth 643c2dbb06 Configure default Twitter summary card type (V2) (#225)
Merge pull request 225
2018-05-02 20:04:19 -04:00
jekyllbot 3414b17660 Update history to reflect merge of #280 [ci skip] 2018-03-24 04:05:43 -04:00
Paweł Zmarzły ddcbe4813f docs/usage - replace "below" with correct link (#280)
Merge pull request 280
2018-03-24 04:05:42 -04:00
jekyllbot 4caedffcac Update history to reflect merge of #250 [ci skip] 2018-03-08 12:04:43 -05:00
Max Chadwick ead4375415 Include page number in title (#250)
Merge pull request 250
2018-03-08 12:04:41 -05:00
Frank Taillandier 3ce93abce7
Merge pull request #253 from antoniotrento/patch-1
Update logo field information
2018-03-08 16:34:32 +01:00
Frank Taillandier ad6392dbd5
Merge branch 'master' into patch-1 2018-03-08 16:31:51 +01:00
Frank Taillandier c116296c7e
addressed feedback 2018-03-08 16:31:36 +01:00
jekyllbot 85933e0903 Update history to reflect merge of #276 [ci skip] 2018-03-08 10:26:14 -05:00
Frank Taillandier 330c5cb616 fix #275 (#276)
Merge pull request 276
2018-03-08 10:26:12 -05:00
Ben Balter f19b29ea0a
Merge pull request #273 from j-f1/patch-1
Don’t process the Liquid example in the advanced usage docs
2018-02-20 09:26:55 -05:00
Jed Fox fb1c56a7a8
Don’t process the Liquid example in the advanced usage docs 2018-02-20 08:20:01 -05:00
Frank Taillandier 1f3858ef0a
Merge pull request #268 from jekyll/pull/fix-267
Prevent {% seo %} Liquid parsing
2018-02-02 15:57:45 +01:00
Frank Taillandier 780c5aa1d0
Prevent {% seo %} Liquid parsing 2018-02-02 10:48:31 +01:00
jekyllbot 46ad253d4d Update history to reflect merge of #263 [ci skip] 2018-01-17 05:44:51 -05:00
Wang Shidong e3e6f8ff6b Add webmaster_verifications for baidu (#263)
Merge pull request 263
2018-01-17 05:44:50 -05:00
Frank Taillandier 15cdb60c9a
Merge pull request #254 from jekyll/copyright-notice
Update Copyright notice
2018-01-14 20:15:27 +01:00
Frank Taillandier f87165b885
Merge branch 'master' into copyright-notice 2018-01-06 22:19:31 +01:00
jekyllbot 47200c437a Update history to reflect merge of #260 [ci skip] 2018-01-05 15:03:00 -05:00
jekyllbot d69e08c773
Test against Ruby 2.5 (#260)
Merge pull request 260
2018-01-05 15:02:59 -05:00
Frank Taillandier 84b81fcef8
Update LICENSE.txt 2018-01-03 19:52:21 +01:00
Frank Taillandier 5b2e69806a
Merge branch 'master' into copyright-notice 2018-01-03 19:51:47 +01:00
jekyllbot 520e78385b Update history to reflect merge of #255 [ci skip] 2017-12-11 14:10:36 -05:00
Sea 551fcaa8f3 Use gems config key for Jekyll < 3.5.0 (#255)
Merge pull request 255
2017-12-11 14:10:35 -05:00
Frank Taillandier 1ec3197ba3
Update LICENSE.txt 2017-12-11 18:40:36 +01:00
Frank Taillandier cbff43dd60
Update Copyright notice
Inspired by
https://ben.balter.com/2015/06/03/copyright-notices-for-websites-and-open-source-projects/
😄
2017-12-11 15:11:02 +01:00
Ben Balter b480dde068
Merge pull request #252 from jekyll/release-2.4.0
Release 2.4.0
2017-12-08 10:59:49 -06:00
Frank Taillandier 19137226ab
Update History.markdown 2017-12-04 23:17:27 +01:00
Antonio Trento 7f73d5edef
Update logo field information
As requested by @benbalter I modified the description in the bulleted list associated with the logo field, thanks to the help
2017-12-04 18:00:19 +01:00
Frank Taillandier e181da90f1 Release 💎 2.4.0
Fix #251
2017-12-04 17:05:37 +01:00
jekyllbot 47259715f7 Update history to reflect merge of #181 [ci skip] 2017-12-04 09:53:18 -06:00
Ben Balter b84e54568f Try testing on Ruby v2.3 and 2.4 (#181)
Merge pull request 181
2017-12-04 09:53:17 -06:00
jekyllbot 2414bee8cc Update history to reflect merge of #242 [ci skip] 2017-12-04 09:22:09 -06:00
jekyllbot 466dc1858a
Travis: Test against Rubies (#242)
Merge pull request 242
2017-12-04 09:22:08 -06:00
jekyllbot fc985bf998 Update history to reflect merge of #243 [ci skip] 2017-12-04 09:20:17 -06:00
jekyllbot c8976c8fb2
Avoid deprecation warning when building docs (#243)
Merge pull request 243
2017-12-04 09:20:16 -06:00
Ben Balter 38b0fbd73a
Merge pull request #249 from jekyll/strip-null-values
Strip null values from JSON-LD hash
2017-11-16 14:36:03 -05:00
Ben Balter da96f4d707
strip null values from JSON-LD hash 2017-11-16 11:40:42 -05:00
Ben Balter ca1200b90f
add failing tests for stripping null values 2017-11-16 11:39:26 -05:00
Frank Taillandier 232d9f91ec
Merge pull request #246 from localheinz/fix/self-closing
Fix: Consistently use self-closing tags
2017-11-09 17:48:54 +01:00
Andreas Möller ce38618ee7
Fix: Consistently use self-closing tags 2017-11-08 23:30:32 +01:00
Frank Taillandier 62de1fb078
Merge pull request #241 from jekyll/pull/rubocop-update
Style: Rubocop auto-correct
2017-11-08 20:43:20 +01:00
Frank Taillandier 59cd2257b6
Style: Rubocop auto-correct 2017-10-22 18:37:44 +02:00
Frank Taillandier 7313ee7e50 Merge pull request #237 from jekyll/unified-bass-drop
Pass the unified drop to the template rather than an ad-hoc payload
2017-09-06 21:37:45 +02:00
Ben Balter e31c9e7ca7
add unit tests for Jekyll::SeoTag 2017-09-06 12:33:19 -04:00
Ben Balter 3805012e9a
Template payload should be a UnifiedPayloadDrop, not a hash 2017-09-06 12:16:10 -04:00
Ben Balter d230d6d885 Merge pull request #236 from DirtyF/meta-generator
Add meta generator
2017-09-06 10:27:31 -04:00
Frank Taillandier a6e78cb7dd
Fix test - props @Parkr 2017-09-06 02:00:09 +02:00
Frank Taillandier f9cabae8a6 add jekyll version to the drop 2017-09-06 01:11:33 +02:00
Frank Taillandier 5219054a76 add test for Jekyll version 2017-09-06 00:34:02 +02:00
Frank Taillandier cc092dd95d
add meta generator 2017-09-05 23:19:27 +02:00
Ben Balter 1b66cb1522
Bump to 2.3.0 2017-08-24 15:07:19 -04:00
Ben Balter cf90f9011a
correct source and dest dir paths in spec helper, props @bogdanvlviv 2017-08-24 14:56:51 -04:00
Ben Balter f3ba20621e Escape __dir__ 2017-08-24 14:42:54 -04:00
Ben Balter 8a1a5332a9 Update for #232 2017-08-24 14:42:38 -04:00
Ben Balter a5463b175c Merge pull request #232 from jekyll/define-path-with-__dir__
Define path with __dir__
2017-08-24 14:40:08 -04:00
Frank Taillandier 89929bf849 Merge branch 'master' into define-path-with-__dir__ 2017-08-24 20:36:39 +02:00
Frank Taillandier ac141413b0
Define path with __dir__ 2017-08-24 20:30:17 +02:00
Ben Balter a3b9e34a3f Update for 2.3.0 2017-08-24 14:27:35 -04:00
Ben Balter 29cbdee3ae Merge pull request #231 from jekyll/cache-template
Cache parsed template
2017-08-24 14:26:06 -04:00
Ben Balter d893fc7646
cache parsed template 2017-08-24 13:22:59 -04:00
Ben Balter 9dc5b01b45 Merge pull request #229 from jekyll/drop-it-like-its-hot
Convert author, image, and JSON-LD to dedicated drops
2017-08-24 13:07:21 -04:00
Ben Balter d79dac001e
whitespace 2017-08-24 13:05:56 -04:00
Ben Balter 1e5b997901
typo in code comment 2017-08-24 13:05:28 -04:00
Ben Balter 83d420113c
add json_ld back to JSONLD to avoid a breaking change 2017-08-24 13:01:43 -04:00
Ben Balter 7ed97c071a Merge pull request #230 from serra/patch-1
gems: is deprecated in current Jekyll version of github-pages
2017-08-24 12:17:22 -04:00
Marijn van der Zee 933bc25bf5 gems: is deprecated in current Jekyll version of github-pages
Jekyll 3.5:

Deprecation: The 'gems' configuration option has been renamed to 'plugins'. Please update your config file accordingly.
2017-08-24 10:40:20 +02:00
Ben Balter 3ef2f613e9
fix regex syntax 2017-08-23 16:50:23 -04:00
Ben Balter 855ef7b469
make the json minification spec explicit 2017-08-23 16:44:33 -04:00
Ben Balter 792abad221
make the json minification test less order dependent 2017-08-23 16:42:05 -04:00
Ben Balter 5219dd13e6
drop the a, just JSON 2017-08-23 16:25:28 -04:00
Ben Balter cf49c63b3c
add tests for JSON-LD drop 2017-08-23 16:20:02 -04:00
Ben Balter 5de6cd7f2c
convert JSON LD to a drop 2017-08-23 16:11:55 -04:00
Ben Balter 298d3b03d6
Drop#image should return nil if there is no image#path in order to avoid a breaking change 2017-08-23 12:18:52 -04:00
Ben Balter 1081a0ebd9
break image logic into its own drop 2017-08-23 12:11:30 -04:00
Ben Balter 2e90fc7238
move author drop tests to their own spec 2017-08-23 11:32:36 -04:00
Ben Balter 891d621899
move author logic to its own drop 2017-08-23 11:07:52 -04:00
Ben Balter f5dbc6c36f Update for #227 2017-08-22 13:11:48 -04:00
Ben Balter 9fbeded5f2 Merge pull request #227 from jekyll/site-authors-array
Ensure site.data.authors is properly formatted before attempting to retrieve author meta
2017-08-22 13:11:01 -04:00
Ben Balter 7b3820f956
correct rubocop offenses 2017-08-22 13:05:49 -04:00
Ben Balter 30b8d8bb48
Merge branch 'site-authors-array' of https://github.com/jekyll/jekyll-seo-tag into site-authors-array 2017-08-22 13:05:26 -04:00
Ben Balter 27392129c4
add explicit test for site.data.authors[author] as a string 2017-08-22 13:05:19 -04:00
Ben Balter 6197b2e7a8 Merge branch 'master' into site-authors-array 2017-08-22 13:03:23 -04:00
Ben Balter 3fca8b4cca Update for #228 2017-08-22 13:02:50 -04:00
Ben Balter ba3b326513 Merge pull request #228 from jekyll/fix-for-invalid-url
Fix for image.path causing an invalid url error
2017-08-22 13:02:26 -04:00
Ben Balter 7cab0247ed
fix for image.path causing an invalid url error 2017-08-22 11:53:18 -04:00
Ben Balter a59b596a2b
comment site_author_hash 2017-08-22 11:41:02 -04:00
Ben Balter f78999819f
ensure site.data.authors is in the expected format before resolving author meta 2017-08-22 11:39:52 -04:00
Ben Balter 6ad02a583d
add failing test for site.authors as an array 2017-08-22 11:31:54 -04:00
Ben Balter 351b04265a
add anchor.js 2017-07-14 12:09:19 -07:00
Ben Balter dfbff0fc2a
fix installation numbering 2017-07-14 11:59:59 -07:00
Ben Balter be9f1a20e3
fix readme h1 2017-07-14 11:59:14 -07:00
Ben Balter ae3b944784
move readme to docs folder because SEO 2017-07-14 11:58:09 -07:00
Ben Balter 3ba744cf43 Merge pull request #212 from jekyll/docs
Move docs to their own folder
2017-07-14 11:52:18 -07:00
Frank Taillandier 8dc1719b81
appease rubocop 2017-07-14 19:39:05 +02:00
Ben Balter fdf081a2b2
move docs to their own folder 2017-05-25 09:50:01 -04:00
Ben Balter 264aabad6f Update history to reflect merge of #211 2017-05-25 09:38:56 -04:00
Ben Balter 445339df18 Merge pull request #211 from 8parth/master
use canonical_url specified in page if present
2017-05-25 09:38:33 -04:00
Ben Balter fb7a346b48
dont use unless and else, per rubocop 2017-05-25 09:35:03 -04:00
Ben Balter 245abc6032
update canoncial URL expectation 2017-05-25 09:34:18 -04:00
Ben Balter bf6b14b167 Explicitly test both canonical URL cases 2017-05-25 09:33:03 -04:00
Ben Balter 83d7c3dd63 s/if !/unless/ 2017-05-25 09:29:09 -04:00
Parth Modi 6f9919bf3e Updated Readme with instructions of setting customized Canonical URL 2017-05-25 11:11:36 +05:30
Parth Modi c07a085e11 Stray puts removed from test of canonical url 2017-05-24 22:35:32 +05:30
Parth Modi ab49d7b5e8 `.present?` changed to `to_s.empty?` as `.present?` is rails specific 2017-05-24 22:35:07 +05:30
Parth Modi 1e6110ddef rubocop offenses fixed 2017-05-24 22:20:44 +05:30
Parth Modi 62956da2de use canonical_url specified in page if present 2017-05-24 22:10:30 +05:30
Ben Balter 7c643224e5 Update History.markdown 2017-05-06 12:29:11 -04:00
Ben Balter a868ab5837
Bump to 2.2.3 2017-05-06 12:18:36 -04:00
Ben Balter 21702b9988 Update for #206 2017-05-05 14:23:13 -04:00
Ben Balter f2e788e0f1 Merge pull request #206 from jekyll/guard-against-empty-strings
Guard against empty title or description strings
2017-05-05 14:22:52 -04:00
Ben Balter 19c6d2ae04
dont double format site title 2017-05-05 09:33:44 -04:00
Ben Balter 604b23e8fc
use site_description as page_description fallback 2017-05-05 09:27:17 -04:00
Ben Balter e637154c53
memoize site_description 2017-05-05 09:25:22 -04:00
Ben Balter e68122d8ce
guard against empty strings not being nil 2017-05-05 09:24:59 -04:00
Ben Balter 96b1fa22c5
add explicit test for all descriptions being nil 2017-05-03 09:08:40 -04:00
Ben Balter 4c3f8048dd Update for #203 2017-05-02 13:49:22 -04:00
Ben Balter 7185353a6c Merge pull request #203 from jekyll/nil-twitter-delete
Guard against the author's Twitter handle being Nil when stripping @'s
2017-05-02 13:48:58 -04:00
Ben Balter 4f80ea50b7
fix for calling delete! on NiLClass 2017-05-02 09:42:21 -04:00
Ben Balter 65820ada36
Add failing test for https://github.com/jekyll/jekyll-seo-tag/issues/202 2017-05-02 09:41:18 -04:00
Ben Balter 908237c7ad
Bump to 2.2.2 2017-05-01 13:00:01 -04:00
Ben Balter 7f79d481a9 Update History.markdown 2017-05-01 12:59:26 -04:00
Ben Balter 753899d017 Update History.markdown 2017-05-01 11:32:43 -04:00
Ben Balter a28cff0466 Merge pull request #199 from jekyll/nil-image-path-fix
Guard against invalid or missing URLs
2017-05-01 11:32:18 -04:00
Frank Taillandier 696b361f19 Merge branch 'master' into nil-image-path-fix 2017-04-26 20:02:36 +02:00
Ben Balter 13bc107b3f
guard against invalid or missing URLs 2017-04-26 12:48:08 -04:00
Ben Balter d00191c1e3
update failing tests for bad URLs 2017-04-26 12:48:00 -04:00
Ben Balter 593d09aacc
failing test for nil image paths 2017-04-26 12:43:10 -04:00
Ben Balter f998cbde12 Update History.markdown 2017-04-26 11:58:36 -04:00
Ben Balter a0c915fb23 Merge pull request #197 from jekyll/guard-against-arrays
Guard against arrays in subhashes
2017-04-26 11:58:18 -04:00
Ben Balter ad25053f0b
ensure subhashes are hashes 2017-04-26 10:52:12 -04:00
Ben Balter b3c2cec0a0
update test expectations 2017-04-26 10:52:03 -04:00
Ben Balter c2f6d1a795
failing test for site.social and page.seo being arrays 2017-04-26 10:45:23 -04:00
Ben Balter b13dda9a45 Merge pull request #194 from jekyll/static-gemfile
Remove dynamic logic from Gemfile
2017-04-25 12:07:37 -04:00
Frank Taillandier 7668593540 Merge branch 'master' into static-gemfile 2017-04-25 17:54:42 +02:00
Ben Balter b756a49f5f Update for 2.2.1 2017-04-25 11:22:06 -04:00
Ben Balter 416a5ca687
Bump to 2.2.1 2017-04-25 11:21:29 -04:00
Ben Balter 982a2c7969
remove dynamic logic from Gemfile 2017-04-25 11:14:58 -04:00
Ben Balter d0b8661a82 Merge pull request #192 from jekyll/author-by-reference
Fix for including name when author is passed by reference
2017-04-25 10:46:53 -04:00
Frank Taillandier e0c8173de2 Merge branch 'master' into author-by-reference 2017-04-13 20:50:17 +02:00
Ben Balter 05c8d9f994 Merge pull request #189 from aav7fl/to_liquid
Fixes #187 Invalid Date
2017-04-13 14:33:26 -04:00
Ben Balter a035ec02bc
fix for including name when author is passed by reference 2017-04-13 13:32:04 -04:00
Kyle Niewiada 48c98cef57 Merge branch 'master' into to_liquid 2017-04-13 13:12:15 -04:00
Ben Balter 812eb22200
add test for front matter defaults 2017-04-13 11:36:49 -04:00
Kyle Niewiada 03cd692f99 Handle nil exception 2017-04-12 10:51:49 -04:00
Kyle Niewiada aa0b47bb8d Fix #187 2017-04-11 19:18:08 -04:00
Ben Balter f048342e22 Update History.markdown 2017-04-11 16:37:47 -05:00
Ben Balter 6a373369e8 Merge pull request #184 from jekyll/drop
Convert seo_author_* logic to a drop
2017-04-11 16:35:25 -05:00
Ben Balter bc0f45ae64
output image as an imageObject if we have additional image properties 2017-04-11 16:33:13 -05:00
Ben Balter a77929d707
Merge branch 'master' into drop 2017-04-11 16:21:56 -05:00
Ben Balter a877451879 Merge pull request #185 from aav7fl/master
Fix issue #183 image.itemtype
2017-04-11 16:21:08 -05:00
Ben Balter 0f8edbce4a
add test for specifying image height and width 2017-04-11 15:29:43 -05:00
Ben Balter 650fe5c1fd
use reduce to format strings 2017-04-11 15:19:17 -05:00
Ben Balter 8cb5953ea4
use addressible to determine absolute urls 2017-04-11 15:15:24 -05:00
Ben Balter cfe7e56cf8
better homepage_or_about detection 2017-04-11 15:13:24 -05:00
Ben Balter ab916c974e
memoize fallback_data 2017-04-11 14:59:45 -05:00
Ben Balter 0a70e8c172
remove stray begin block 2017-04-11 14:59:19 -05:00
Ben Balter ee1b03cd0a
memoize name 2017-04-11 14:58:10 -05:00
Ben Balter 993eafce00
memoize title? 2017-04-11 14:54:21 -05:00
Ben Balter 791db5107c
check author passed as a hash in json-ld 2017-04-11 14:45:49 -05:00
Kyle Niewiada dfacea2a9c Appease lord RuboCop 2017-04-11 12:05:31 -04:00
Kyle Niewiada 1125c10767 change wording 2017-04-11 11:58:01 -04:00
Kyle Niewiada eb87a06815 Merge branch 'master' into master 2017-04-11 11:25:06 -04:00
Kyle Niewiada 533c6502f2 Fix issue #183 image.itemtype 2017-04-11 11:14:13 -04:00
Ben Balter d2f053dd43
add datePublished to JSON-LD schema 2017-04-10 09:58:41 -05:00
Ben Balter de12942f36
remove unused date method 2017-04-08 14:31:59 -04:00
Ben Balter 9c06b710e6
call it an integration spec 2017-04-08 14:29:53 -04:00
Ben Balter 6eaae965f8
silence Jekyll output 2017-04-08 14:29:24 -04:00
Ben Balter 8a3cd3f9e3
specify timezone in tests 2017-04-08 14:27:45 -04:00
Ben Balter 66aff234ca
use ruby to generate json-ld 2017-04-08 14:20:21 -04:00
Ben Balter 337bffa3bc
use attr_accessor 2017-04-07 17:10:13 -04:00
Ben Balter fa44b31280
add spec for filters class 2017-04-07 17:06:03 -04:00
Ben Balter dea21f0f8d
move filters to their own class 2017-04-07 17:01:20 -04:00
Ben Balter 0fd1bdcdfc
ensure to_h doesnt cause things to explode 2017-04-07 16:51:37 -04:00
Ben Balter 7885669ee6
memoize drop 2017-04-07 16:37:21 -04:00
Ben Balter 3797b19a7d
make rubocop happy 2017-04-07 16:35:20 -04:00
Ben Balter 9620da0224
simplify tests 2017-04-07 16:34:01 -04:00
Ben Balter efab796817
add image specs 2017-04-07 16:27:41 -04:00
Ben Balter 44d52ca4b7
moar tests 2017-04-07 16:20:54 -04:00
Ben Balter 326e35683f
memoize all the things 2017-04-07 13:39:05 -04:00
Ben Balter 96e9823561
add tests for drop 2017-04-06 22:34:11 -04:00
Ben Balter 058b337aba
escape urls 2017-04-06 19:07:40 -04:00
Ben Balter b9cd5de1d0
remove stubbed context 2017-04-06 19:06:31 -04:00
Ben Balter 25f1401d96
rubocop 2017-04-06 19:04:24 -04:00
Ben Balter f88db117f1
convert logic to a drop 2017-04-06 19:02:32 -04:00
Ben Balter f84ad32a2f Mark 2.2.0 2017-04-06 15:05:27 -04:00
Ben Balter 7ab08dcfcc
Bump to 2.2.0 2017-04-06 15:04:55 -04:00
Ben Balter a4e147b208 Update History.markdown 2017-04-06 15:03:42 -04:00
Ben Balter 11cd72c914 Merge pull request #151 from aav7fl/master
Add tags to JSON metadata
2017-04-06 15:02:04 -04:00
Kyle Niewiada 5b2e8f31ca Merge branch 'master' into master 2017-04-04 13:37:50 -04:00
Ben Balter 2744abab0b Update History.markdown 2017-04-04 13:30:00 -04:00
Kyle Niewiada 61d4c91f3e Remove date default handle 2017-04-04 13:15:12 -04:00
Kyle Niewiada 9ec685a31b Merge branch 'master' into master 2017-04-04 11:51:05 -04:00
Ben Balter 271cba1397 Merge pull request #180 from jekyll/drop-rake
Remove Rake dependency
2017-04-04 10:51:01 -04:00
Ben Balter f57ddb9c89
remove Rake dependency 2017-04-04 10:43:34 -04:00
Ben Balter e9797f3a98 Merge pull request #172 from DirtyF/bump-dev-dependencies
Bump dev dependencies
2017-04-04 10:40:26 -04:00
Ben Balter 5feed54146
Merge branch 'bump-dev-dependencies' of https://github.com/DirtyF/jekyll-seo-tag into bump-dev-dependencies 2017-04-04 09:56:39 -04:00
Ben Balter 8e8b11aab7
update to use new html proofer api 2017-04-04 09:52:27 -04:00
Ben Balter 7de7c7a497
require html-proofer, not html/proofer 2017-04-04 09:50:57 -04:00
Ben Balter 93de3ca46b Merge branch 'master' into bump-dev-dependencies 2017-04-04 09:49:48 -04:00
Ben Balter 46c8238f50
Merge branch 'bump-dev-dependencies' of https://github.com/DirtyF/jekyll-seo-tag into DirtyF-bump-dev-dependencies 2017-04-04 09:47:21 -04:00
Ben Balter 28093bfe56 Merge pull request #171 from DirtyF/clean-Gemfile
No need to delete Jekyll's version from Gemfile
2017-04-04 09:46:35 -04:00
Ben Balter 9183898ad7 Merge branch 'master' into bump-dev-dependencies 2017-04-04 09:44:13 -04:00
Ben Balter 5567308e86 Merge branch 'master' into clean-Gemfile 2017-04-04 09:42:41 -04:00
Ben Balter dcf646c8d0 Merge pull request #166 from aarongustafson/add-locale-support
Add og:locale support
2017-04-04 09:40:54 -04:00
Aaron Gustafson 4f919b2aaa Anticitating Rubocop 2017-04-03 20:05:24 -04:00
Aaron Gustafson 8a8a5e9859 Added hyphen to underscore coersion 2017-04-03 20:04:29 -04:00
Kyle Niewiada 6009b495ea Separate tests. 2017-04-03 15:25:57 -04:00
Aaron Gustafson a2f64d46c3 Merge branch 'master' into add-locale-support 2017-04-03 15:10:14 -04:00
Aaron Gustafson 18ec5736c2 Variable rename 2017-04-03 15:09:35 -04:00
Aaron Gustafson e2114abbb7 Fixing the documentation 2017-04-03 14:41:21 -04:00
Kyle Niewiada bc32658d36 Clarify documentation 2017-04-03 14:25:29 -04:00
Kyle Niewiada ac0886dbf2 Merge branch 'master' into master 2017-04-03 13:51:25 -04:00
Ben Balter 32ec9300dc Merge pull request #174 from jhabdas/twitter-uses-og-image
refactor(template): use og:image for twitter
2017-04-03 13:51:00 -04:00
Kyle Niewiada 48ba285251 Image changes should be removed 2017-04-03 13:36:45 -04:00
Kyle Niewiada e8e54a924c Merge branch 'master' into master 2017-04-03 13:11:19 -04:00
Josh Habdas e264a9a94b
refactor(template): use og:image for twitter
#77 and #78 added support for different images on Twitter and Facebook, an advanced feature of SEO
Tag Gem. The implementation has led to complications updating JSON-LD data in #151. Under Pareto
principal we can reasonably assume this feature is not often used, and, as such, should be removed.
The result of which simplifies template logic, offers a fallback experience by leverages Twitter's
use of `og:image` in place of `twitter:image` (sees twitter card tag ref) and helps unblock #151.

Users can no longer specify a separate twitter and Facebook image. If both a Facebook (Open Graph)
and Twitter image are provided in the `image` object, the Facebook image will take precedence.
2017-04-04 00:58:53 +08:00
Aaron Gustafson b3d5db3563 Fixing Rubocop offenses 2017-04-03 11:32:31 -04:00
Aaron Gustafson a1e5b4e53d Merge remote-tracking branch 'upstream/master' into add-locale-support 2017-04-03 11:26:11 -04:00
Aaron Gustafson abf32914b7 Switching to site.lang & page.lang to align with jekyll-feed 2017-04-03 11:21:48 -04:00
Aaron Gustafson 8a5b022a89 Adding /bin/ to mask local testing 2017-04-03 11:11:59 -04:00
Ben Balter dc767f10cc Merge pull request #170 from DirtyF/rubocop-offenses
bump and appease Rubocop
2017-04-03 09:59:59 -04:00
Frank Taillandier 4be9613191 Disable Style/IndentHeredoc on specs 2017-03-31 23:55:49 +02:00
Frank Taillandier ef8fe3106c bump and appease Rubocop 2017-03-31 22:42:46 +02:00
Frank Taillandier 2172ada23b bump dev dependencies 2017-03-31 22:34:43 +02:00
Frank Taillandier 5f3260809e No need to delete Jekyll's version from Gemfile
Github Pages supports Jekyll 3.4.3
2017-03-31 21:39:22 +02:00
Aaron Gustafson 2191a550ee Test cleanup 2017-03-31 14:41:46 -04:00
Aaron Gustafson 179530d885 Added documentation 2017-03-31 14:31:16 -04:00
Aaron Gustafson 59b20c7bf9 Added test 2017-03-31 14:26:58 -04:00
Aaron Gustafson 308cf7a523 Added support for locale exposure as `og:locale` 2017-03-31 14:22:08 -04:00
Kyle Niewiada 0b289b820b Merge branch 'master' into master 2017-03-03 08:16:11 -05:00
Ben Balter 4aedc4f7e3 Merge pull request #162 from jhabdas/moz-separator
Update title separator. Closes #121
2017-03-02 11:12:01 -05:00
Josh Habdas 2a48f272f6
Be more explicity with title assignments 2017-03-02 21:29:26 +08:00
Josh Habdas 51db5806c2
Correct template logic, resolve style issues 2017-03-02 20:24:13 +08:00
Josh Habdas 4eeb09a749
Update title separator. Closes #121
Replaces the "-" used as a title separator with "|".
Ref: https://moz.com/learn/seo/title-tag

Also updates docs to specify title optional and fix errata.
2017-03-02 12:15:09 +08:00
Kyle Niewiada 74c2d3dbe7 Code deprecated note 2017-02-25 10:23:40 -05:00
Kyle Niewiada 89aad3b9e0 Merge pull request #1 from aav7fl/testing
Better test coverage. Refactored.
2017-02-24 15:06:32 -05:00
Kyle Niewiada c31f4c65b1 Better test coverage. Some overlap, but easier to understand. Some tests slightly refactored. 2017-02-24 15:04:36 -05:00
Kyle Niewiada 3410feec97 Merge branch 'master' into master 2017-02-21 21:47:05 -05:00
Ben Balter a814dc6f0f Merge pull request #160 from renshuki/metaname-author-unit-tests
Add specs for author metadata
2017-02-21 11:00:55 -05:00
renshuki 87b4cd7807 Add specs for author metadata 2017-02-18 18:13:50 +09:00
Kyle Niewiada 02eb926293 Appease RuboCop 2017-02-17 10:33:39 -05:00
Kyle Niewiada 4c577ffb47 Add legacy test and maintain old methods 2017-02-17 10:30:44 -05:00
Kyle Niewiada 318de343b0 Remove unnecessary/confusing wording. 2017-02-16 14:49:06 -05:00
Kyle Niewiada a847a69eea Fix small test case blunder. 2017-02-16 14:16:11 -05:00
Kyle Niewiada ba16b955c8 Propose new image handling method. 2017-02-16 14:07:35 -05:00
Kyle Niewiada 8e36fe4da1 Update docs. Add use case. Add test. 2017-02-15 12:41:30 -05:00
Kyle Niewiada cc02710dbf Merge branch 'master' into master 2017-02-15 10:00:52 -05:00
Ben Balter 7a55ccd04d Update history to reflect merge of #103 2017-02-13 10:07:16 -05:00
Ben Balter 0acae1650a
Merge branch 'renshuki-master' 2017-02-13 10:05:56 -05:00
Ben Balter fa96401540
Merge branch 'master' of https://github.com/renshuki/jekyll-seo-tag into renshuki-master 2017-02-13 10:04:12 -05:00
kyle 6ebc866c5e Appease RuboCop 2017-01-30 10:46:22 -05:00
Kyle Niewiada 987e1ea81c Merge branch 'master' into master 2017-01-30 10:38:18 -05:00
kyle da498c7c5f Simplify documentation. Change to snake_case. Use Path instead of adding URL. 2017-01-30 10:37:27 -05:00
Ben Balter 143451a12e Merge pull request #157 from renshuki/fix-rubocop-multiline-hash-errors
Fix rubocop multiline hash errors
2017-01-30 09:53:18 -05:00
renshuki e91babe998 Fix rubocop multiline hash errors 2017-01-30 10:53:19 +09:00
renshuki 903f9efab9 Implement seo_author.name 2017-01-29 04:33:50 +09:00
renshuki 81c9bc8fa4 Add author meta 2017-01-29 02:57:04 +09:00
kyle a0f65888e3 Remove Author tag. I guess it really isn't used anymore. 2017-01-25 12:18:29 -05:00
kyle 644e976fbd Add test for PR #103 2017-01-25 11:37:35 -05:00
kyle 5437934214 Implement PR #103 for my own use. Change template to better fit existing style. 2017-01-25 11:35:18 -05:00
kyle fd5246a4cd Test output manually with Google Markup. Change inferred type. Improve test coverage 2017-01-25 11:05:38 -05:00
kyle b04f73960e Match rubocop styling. 2017-01-18 15:28:54 -05:00
kyle 10d5f82984 Travis doesn't like my timestamps for testing. 2017-01-18 15:01:48 -05:00
kyle 9aa2cbfb09 Wite tests for implemented features. 2017-01-18 14:57:36 -05:00
kyle 8cc9b2d52c Add test for image object with dimensions 2017-01-18 14:14:29 -05:00
Kyle Niewiada a2a2c560ce Add pull request documentation
Adds documentation on new image behavior, dateModified, and author field.
2017-01-17 11:20:48 -05:00
Kyle Niewiada 30d4ffc1a3 Fix language mistake
Well.... looks like I added an 'e'. Whoops.
2017-01-17 09:50:54 -05:00
Kyle Niewiada 4868d22b1b Add the rest of the JSON tags to pass blogPosting Errors/Warnings
This adds the rest of the JSON fields to pass all errors and blog postings.

- Adds page.image.url for the image url. (Will default to image if not present). 
- Add page.image.height and page.image.width for an image object (Will default back to image url if not present). 
- Add dateModified (will capture from yaml if present, if not it will use datePublished)
  - (I feel there should be a manual option for this as I sometimes save parts of my blog that shouldn't update the modified field, but still 
change the file timestamp).

This should create JSON that will pass all warnings/strong recommendations/errors from [Google's Structured Data Testing Tool](https://search.google.com/structured-data/testing-tool).
2017-01-17 09:39:41 -05:00
Kyle Niewiada 2ddab030f3 Fix word casing 2017-01-16 17:49:37 -05:00
Kyle Niewiada 8d2febf86c Fix typo. Oops. 2017-01-16 17:21:08 -05:00
Kyle Niewiada f82ea47534 Fix Google Structured Data Requests
Fixes missing author and name in blogPosting types with organization.
2017-01-16 17:18:50 -05:00
jekyllbot 0b656aca3b Update history to reflect merge of #148 [ci skip] 2017-01-13 10:24:27 -05:00
jekyllbot c859774133 Merge pull request #148 from jhabdas/bing-yandex-webmaster
Merge pull request 148
2017-01-13 10:24:26 -05:00
jekyllbot 062072bcd4 Update history to reflect merge of #149 [ci skip] 2017-01-13 10:18:08 -05:00
jekyllbot 9bd61a3ba1 Merge pull request #149 from jekyll/pr/exclude-spec
Merge pull request 149
2017-01-13 10:18:07 -05:00
Pat Hawks 311f25d06d
Don't worry if tests are too long 2017-01-12 23:34:49 -06:00
Josh Habdas a321a7f2f7
Incorporate feedback, add unit tests 2017-01-13 12:48:55 +08:00
Josh Habdas 0dea0333d2
Add support for Bing and Yandex webmaster tools. Closes #147 2017-01-12 14:22:00 +08:00
Ben Balter 72f0432c25 Update history to reflect v2.1.0 2016-11-02 16:48:55 -04:00
Ben Balter 97c5bf0e63 Bump to 2.1.0 2016-11-02 16:47:37 -04:00
jekyllbot 9272d98f64 Update history to reflect merge of #139 [ci skip] 2016-10-28 13:00:08 -07:00
jekyllbot 21e5bc2b4d Merge pull request #139 from DirtyF/patch-1
Merge pull request 139
2016-10-28 13:00:07 -07:00
Frank Taillandier a9bbb7935d
fix indentation 2016-10-28 19:32:33 +02:00
Frank Taillandier 781b0c7399 add example usage of social profiles
fix #138
2016-10-28 17:12:17 +02:00
Ben Balter 23b7e0bba2 Update history to reflect prior commits 2016-10-23 16:59:07 -04:00
jekyllbot 01bb0432a2 Update history to reflect merge of #133 [ci skip] 2016-10-23 13:49:49 -07:00
jekyllbot 5163c0cbc9 Merge pull request #133 from daviddarnes/patch-1
Merge pull request 133
2016-10-23 13:49:49 -07:00
Pat Hawks f90fb32d25
Update tests for new position of logo 2016-10-23 14:48:11 -05:00
David Darnes d999dc0a7e Wraps logo image json data in a publisher property
Fixes #89
2016-10-23 20:19:59 +01:00
jekyllbot ebb94f5b25 Update history to reflect merge of #132 [ci skip] 2016-10-23 09:18:23 -07:00
jekyllbot 970f750219 Merge pull request #132 from DirtyF/default-image
Merge pull request 132
2016-10-23 09:18:22 -07:00
Frank Taillandier 753173df76
Add front matter default example for image 2016-10-23 16:28:56 +02:00
Ben Balter 6d133fd352 Merge pull request #126 from jekyll/pull/dont-mangle-text
Don't mangle text with newlines
2016-10-20 11:39:53 -04:00
Pat Hawks d7a67b563f Don't mangle text with newlines
Fixes #117
2016-10-19 19:04:42 -05:00
43 changed files with 3484 additions and 888 deletions

103
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,103 @@
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
j4:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
runs-on: 'ubuntu-latest'
env:
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
- 2.7
- 3.1
jekyll_version:
- "~> 4.0"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Execute tests
run: bundle exec rspec
j3:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
runs-on: 'ubuntu-latest'
env:
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
jekyll_version:
- "~> 3.9"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Execute tests
run: bundle exec rspec
style_check:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: "Code Style Check (Ruby ${{ matrix.ruby_version }})"
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Check Style Offenses
run: bundle exec rubocop -S -D
gem_build:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: "Test Gem build (Ruby ${{ matrix.ruby_version }})"
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Test Gem build
run: bundle exec gem build jekyll-seo-tag.gemspec

33
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: Release Gem
on:
push:
branches:
- master
paths:
- "lib/**/version.rb"
jobs:
release:
if: "github.repository_owner == 'jekyll'"
name: "Release Gem (Ruby ${{ matrix.ruby_version }})"
runs-on: "ubuntu-latest"
strategy:
fail-fast: true
matrix:
ruby_version:
- 2.7
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Build and Publish Gem
uses: ashmaroli/release-gem@dist
with:
gemspec_name: jekyll-seo-tag
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }}

4
.github/workflows/scripts/memprof vendored Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
bundle exec ruby jekyll-seo-tag/.github/workflows/scripts/memprof.rb sandbox
exit 0

14
.github/workflows/scripts/memprof.rb vendored Normal file
View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
require 'jekyll'
require 'memory_profiler'
MemoryProfiler.report(allow_files: 'lib/jekyll-seo-tag') do
Jekyll::PluginManager.require_from_bundler
Jekyll::Commands::Build.process({
"source" => File.expand_path(ARGV[0]),
"destination" => File.expand_path("#{ARGV[0]}/_site"),
"disable_disk_cache" => true,
})
puts ''
end.pretty_print(scale_bytes: true, normalize_paths: true)

63
.github/workflows/third-party.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Third-Party Repository Profiling
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_n_profile:
name: "Third-Party Repo Profile (Jekyll ${{ matrix.jekyll_version }}, Ruby ${{ matrix.ruby_version }})"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
ruby_version:
- 2.7
jekyll_version:
- "~> 4.0"
- "~> 3.9"
env:
BUNDLE_GEMFILE: "sandbox/Gemfile"
BUNDLE_PATH: "vendor/bundle"
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
JEKYLL_VERSION: ${{ matrix.jekyll_version }}
steps:
- name: Checkout Jekyll SEO Tag
uses: actions/checkout@v2
with:
fetch-depth: 5
path: jekyll-seo-tag
- name: Checkout Third-Party Repository (WITHOUT SEO Tag)
uses: actions/checkout@v2
with:
repository: ashmaroli/tomjoht.github.io
ref: "no-seo-tag"
path: alpha-sandbox
- name: Checkout Same Third-Party Repository (WITH SEO Tag)
uses: actions/checkout@v2
with:
repository: ashmaroli/tomjoht.github.io
ref: "seo-tag"
path: sandbox
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Run Jekyll Build (WITHOUT SEO Tag) 3 times
run: |
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
- name: Run Jekyll Build (WITH SEO Tag) 3 times
run: |
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
bundle exec jekyll build -s sandbox -d sandbox/_site --trace
- name: Memory Analysis of Jekyll Build (WITH SEO Tag)
run: bash jekyll-seo-tag/.github/workflows/scripts/memprof
if: "!contains(matrix.jekyll_version, '3.')"

17
.gitignore vendored
View File

@ -1,10 +1,9 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.gem
.bundle
.yardoc
Gemfile.lock
pkg
spec/reports/
spec/fixtures/.jekyll-cache
tmp/
vendor/bundle

2
.rspec
View File

@ -1,2 +1,2 @@
--format documentation
--color
--require spec_helper

View File

@ -1,17 +1,42 @@
inherit_gem:
jekyll: .rubocop.yml
inherit_from: .rubocop_todo.yml
Metrics/LineLength:
require: rubocop-jekyll
inherit_gem:
rubocop-jekyll: .rubocop.yml
AllCops:
TargetRubyVersion: 2.5
SuggestExtensions: false
Exclude:
- vendor/**/*
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Layout/LineLength:
Exclude:
- spec/**/*
- jekyll-seo-tag.gemspec
Style/Documentation:
Lint/EmptyInPattern:
Enabled: false
Style/FileName:
Enabled: false
AllCops:
Metrics/BlockLength:
Exclude:
- vendor/**/*
- spec/**/*
Naming/InclusiveLanguage:
Enabled: false
Performance/MapCompact:
Enabled: true
Performance/RedundantEqualityComparisonBlock:
Enabled: true
Performance/RedundantSplitRegexpArgument:
Enabled: true
Style/InPatternThen:
Enabled: false
Style/MultilineInPatternThen:
Enabled: false
Style/QuotedSymbols:
Enabled: true

46
.rubocop_todo.yml Normal file
View File

@ -0,0 +1,46 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude`
# on 2021-09-17 06:40:32 UTC using RuboCop version 1.18.4.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Configuration parameters: AllowComments.
Lint/EmptyClass:
Exclude:
- 'lib/jekyll-seo-tag/version.rb'
# Offense count: 3
Lint/NoReturnInBeginEndBlocks:
Exclude:
- 'lib/jekyll-seo-tag/author_drop.rb'
- 'lib/jekyll-seo-tag/drop.rb'
# Offense count: 1
# Cop supports --auto-correct.
Lint/ToJSON:
Exclude:
- 'lib/jekyll-seo-tag/json_ld_drop.rb'
# Offense count: 1
# Configuration parameters: IgnoredMethods, Max.
Metrics/PerceivedComplexity:
Exclude:
- 'lib/jekyll-seo-tag/drop.rb'
# Offense count: 1
# Configuration parameters: MinSize.
Performance/CollectionLiteralInLoop:
Exclude:
- 'spec/jekyll_seo_tag/author_drop_spec.rb'
# Offense count: 9
# Cop supports --auto-correct.
Style/RedundantBegin:
Exclude:
- 'lib/jekyll-seo-tag.rb'
- 'lib/jekyll-seo-tag/author_drop.rb'
- 'lib/jekyll-seo-tag/drop.rb'
- 'lib/jekyll-seo-tag/image_drop.rb'

View File

@ -1,7 +0,0 @@
rvm:
- 2.2.3
before_install: gem install bundler
language: ruby
script: script/cibuild
sudo: false
cache: bundler

19
Gemfile
View File

@ -1,17 +1,8 @@
source 'https://rubygems.org'
require 'json'
require 'open-uri'
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
group :development, :test do
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
versions.delete('ruby')
versions.delete('jekyll-seo-tag')
versions.delete('github-pages')
versions.delete('jekyll') # Remove this line when GitHub Pages supports 3.3.0
versions.each do |dep, version|
gem dep, version
end
end
gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"]
gem "kramdown-parser-gfm" if ENV["JEKYLL_VERSION"] == "~> 3.9"

228
History.markdown Normal file
View File

@ -0,0 +1,228 @@
## HEAD
### Development Fixes
* Add Ruby 3.1 to CI matrix (#459)
* chore: remove git.io (#462)
### Minor Enhancements
* Added the `twitter:description` tag (#464)
* Support for image paths relative to the page&#39;s directory (#466)
* Truncate the description value to 100 words (#492)
## 2.8.0 / 2022-02-04
### Minor Enhancements
* Allow to set type for author (#427)
* Allow setting `author.url` (#453)
* Implement Facebook domain verification (#455)
* Add `og:image:alt` and `twitter:image:alt` (#438)
* Sort JSON-LD data by key (#458)
### Bug Fixes
* Set the default `og:type` to &#39;website&#39; (#391)
* Template: Remove double new line (#454)
### Development Fixes
* Fix typo in source code comment (#449)
* Set up Continuous Integration via GH Actions (#450)
* Bump RuboCop to v1.18.x (#452)
* Add workflow to release gem via GH Actions
## 2.7.1 / 2020-10-18
### Development Fixes
* refactor: mutate site payload instead of duplicating it (#419)
## 2.7.0 / 2020-10-18
### Minor Enhancements
* Change pagination message with `seo_paginator_message` option (#324)
* Make Twitter Summary Card without having Twitter account (#284)
* Prefer site.tagline to site.description for page title (#356)
* Render og:locale meta only when defined explicitly (#388)
### Bug Fixes
* Ensure a single leading `@` for twitter usernames (#367)
### Development Fixes
* chore(deps): require Ruby > 2.4.0 EOL
* test: fix locale specs that use the fallback locale (#360)
* refactor: Replace read-only empty hash with private constant (#418)
* refactor: Mutate hash literals instead of duplicating them (#417)
* refactor: Reduce allocations of instance-agnostic objects (#376)
* refactor: Memoize #author_hash in SeoTag::AuthorDrop (#342)
* refactor: simplify conditional in SeoTag::Drop#date_modified (#343)
* chore(ci): profile seo-tag plugin on a third-party repository (#414)
* chore(ci): Jekyll v4.0 (#372)
* chore(ci): test against current stable Ruby 2.5 and 2.7 (#385)
* style: align with latest jekyll-rubocop (#382)
* fix: Travis builds for Jekyll 3.x (#415)
### Documentation
* Structured Data Testing Tool is deprecated (#409)
* Rename Google webmaster tools to Google Search Console (#403)
* Improve documentation on plugin usage (#399)
* remove Google+ from example snippet (#358)
* HTTPS link to https://ogp.me/ (#359)
* HTTPS links to schema.org (#350)
* use example.com for example URL (#351)
## 2.6.1 / 2019-05-17
### Development Fixes
* Test against Jekyll 4.x (#336)
## 2.6.0 / 2019-03-16
### Minor Enhancements
* Twitter Image and Title (#330)
### Bug Fixes
* Do not cache the drop payload for SeoTag (#306)
* Update url of schema website (#296)
### Development Fixes
* Relax version constraint on Bundler (#325)
* chore(ci): Add Ruby 2.6, drop Ruby 2.3 (#326)
* chore (ci): remove deprecated `sudo: false` in .travis.yml (#333)
* Lint Ruby code with rubocop-jekyll gem (#302)
* chore(deps): bump rubocop-jekyll to v0.4 (#320)
* chore(deps): bump rubocop-jekyll to v0.3 (#316)
* Correct RuboCop offenses in spec files (#319)
### Documentation
* Rectify error in Usage documentation (#328)
## 2.5.0 / 2018-05-18
* Docs: Prevent GitHub Pages from processing Liquid raw tag (#276)
### Documentation
* Use gems config key for Jekyll &lt; 3.5.0 (#255)
* docs/usage - replace &#34;below&#34; with correct link (#280)
### Development Fixes
* Test against Ruby 2.5 (#260)
* add tests for twitter.card types (#289)
* Target Ruby 2.3 and Rubocop 0.56.0 (#292)
### Minor Enhancements
* Add webmaster_verifications for baidu (#263)
* Include page number in title (#250)
* Configure default Twitter summary card type (V2) (#225)
## 2.4.0 / 2017-12-04
### Minor
* Add meta generator (#236)
* Consistently use self-closing tags (#246)
* Strip null values from JSON-LD hash (#249)
### Documentation
* Avoid deprecation warning when building docs (#243)
### Development Fixes
* Test against latest Rubies (#242)
* Use Nokigiri on CI (#181)
## 2.3.0
### Minor Enhancements
* Use canonical_url specified in page if present #211
* Fix for image.path causing an invalid url error #228
* Ensure `site.data.authors` is properly formatted before attempting to retrieve author meta #227
* Convert author, image, and JSON-LD to dedicated drops #229
* Cache parsed template #231
* Define path with `__dir__` #232
### Documentation
* gems: is deprecated in current Jekyll version of github-pages #230
## 2.2.3
* Guard against the author's Twitter handle being Nil when stripping @'s #203
* Guard against empty title or description strings #206
## 2.2.2
### Minor Enhancements
* Guard against arrays in subhashes #197
* Guard against invalid or missing URLs #199
### Development fixes
* Remove dynamic GitHub Pages logic from Gemfile #194
## 2.2.1
* Convert template logic to a Liquid Drop (significant performance improvement) (#184)
* Fix for JSON-LD validation warning for images missing required properties (#183)
## 2.2.0
### Major Enhancements
* Add author meta (#103)
* Add og:locale support #166
* Add support for Bing and Yandex webmaster tools. Closes #147 (#148)
* Add SEO author and date modified to validate JSON-LD output (#151)
### Minor Enhancements
* Use `|` for title separator (#162)
* Use `og:image` for twitter image (#174)
### Development Fixes
* Style fixes (#170, #157, #149)
* Test against latest version of Jekyll (#171)
* Bump dev dependencies (#172)
* Remove Rake dependency (#180)
## 2.1.0
### Major Enhancement
* Use new URL filters (#123)
### Minor Enhancements
* Wraps logo image json data in a publisher property (#133)
* Fix duplicated `escape_once` (#93)
* Simplify minify regex (#125)
* Don't mangle text with newlines #126
### Documentation
* Add front matter default example for image (#132)
* Fix tiny typo (#106)
* add example usage of social profiles (#139)
### Development
* Inherit Jekyll's rubocop config for consistency (#109)
* Correct spelling in .travis.yml (#112)

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 Ben Balter
Copyright (c) 2015-present Ben Balter and the jekyll-seo-tag contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

189
README.md
View File

@ -1,189 +0,0 @@
# Jekyll SEO Tag
A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
[![Gem Version](https://badge.fury.io/rb/jekyll-seo-tag.svg)](https://badge.fury.io/rb/jekyll-seo-tag) [![Build Status](https://travis-ci.org/jekyll/jekyll-seo-tag.svg)](https://travis-ci.org/jekyll/jekyll-seo-tag)
## What it does
Jekyll SEO Tag adds the following meta tags to your site:
* Pages title (with site title appended when available)
* Page description
* Canonical URL
* Next and previous URLs on paginated pages
* [JSON-LD Site and post metadata](https://developers.google.com/structured-data/) for richer indexing
* [Open graph](http://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
* [Twitter summary card](https://dev.twitter.com/cards/overview) metadata
While you could theoretically add the necessary metadata tags yourself, Jekyll SEO Tag provides a battle-tested template of crowdsourced best-practices.
## What it doesn't do
Jekyll SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display. If you're looking for something to analyze your Jekyll site's structure and content (e.g., more traditional SEO optimization), take a look at [The Jekyll SEO Gem](https://github.com/pmarsceill/jekyll-seo-gem).
Jekyll SEO tag isn't designed to accommodate every possible use case. It should work for most site out of the box and without a laundry list of configuration options that serve only to confuse most users.
## Installation
1. Add the following to your site's `Gemfile`:
```ruby
gem 'jekyll-seo-tag'
```
2. Add the following to your site's `_config.yml`:
```yml
gems:
- jekyll-seo-tag
```
3. Add the following right before `</head>` in your site's template(s):
```liquid
{% seo %}
```
## Usage
The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if they're not defined):
* `title` - Your site's title (e.g., Ben's awesome site, The GitHub Blog, etc.)
* `description` - A short description (e.g., A blog dedicated to reviewing cat gifs)
* `url` - The full URL to your site. Note: `site.github.url` will be used by default.
* `author` - global author information (see below)
* `twitter:username` - The site's Twitter handle. You'll want to describe it like so:
```yml
twitter:
username: benbalter
```
* `facebook` - The following properties are available:
* `facebook:app_id` - a Facebook app ID for Facebook insights
* `facebook:publisher` - a Facebook page URL or ID of the publishing entity
* `facebook:admins` - a Facebook user ID for domain insights linked to a personal account
You'll want to describe one or more like so:
```yml
facebook:
app_id: 1234
publisher: 1234
admins: 1234
```
* `logo` - URL to a site-wide logo (e.g., `/assets/your-company-logo.png`)
* `social` - For [specifying social profiles](https://developers.google.com/structured-data/customize/social-profiles). The following properties are available:
* `name` - If the user or organization name differs from the site's name
* `links` - An array of links to social media profiles.
* `google_site_verification` for verifying ownership via Google webmaster tools
The SEO tag will respect the following YAML front matter if included in a post, page, or document:
* `title` - The title of the post, page, or document
* `description` - A short description of the page's content
* `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`)
* `author` - Page-, post-, or document-specific author information (see below)
## Advanced usage
Jekyll SEO Tag is designed to implement SEO best practices by default and to be the right fit for most sites right out of the box. If for some reason, you need more control over the output, read on:
### Disabling `<title>` output
If for some reason, you don't want the plugin to output `<title>` tags on each page, simply invoke the plugin within your template like so:
```
{% seo title=false %}
```
### Author information
Author information is used to propagate the `creator` field of Twitter summary cards. This should be an author-specific, not site-wide Twitter handle (the site-wide username be stored as `site.twitter.username`).
*TL;DR: In most cases, put `author: [your Twitter handle]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.*
There are several ways to convey this author-specific information. Author information is found in the following order of priority:
1. An `author` object, in the documents's front matter, e.g.:
```yml
author:
twitter: benbalter
```
2. An `author` object, in the site's `_config.yml`, e.g.:
```yml
author:
twitter: benbalter
```
3. `site.data.authors[author]`, if an author is specified in the document's front matter, and a corresponding key exists in `site.data.authors`. E.g., you have the following in the document's front matter:
```yml
author: benbalter
```
And you have the following in `_data/authors.yml`:
```yml
benbalter:
picture: /img/benbalter.png
twitter: jekyllrb
potus:
picture: /img/potus.png
twitter: whitehouse
```
In the above example, the author `benbalter`'s Twitter handle will be resolved to `@jekyllrb`. This allows you to centralize author information in a single `_data/authors` file for site with many authors that require more than just the author's username.
*Pro-tip: If `authors` is present in the document's front matter as an array (and `author` is not), the plugin will use the first author listed, as Twitter supports only one author.*
4. An author in the document's front matter (the simplest way), e.g.:
```yml
author: benbalter
```
5. An author in the site's `_config.yml`, e.g.:
```yml
author: benbalter
```
### Customizing JSON-LD output
The following options can be set for any particular page. While the default options are meant to serve most users in the most common circumstances, there may be situations where more precise control is necessary.
* `seo`
* `name` - If the name of the thing that the page represents is different from the page title. (i.e.: "Frank's Café" vs "Welcome to Frank's Café")
* `type` - The type of things that the page represents. This must be a [Schema.org type](http://schema.org/docs/schemas.html), and will probably usually be something like [`BlogPosting`](http://schema.org/BlogPosting), [`NewsArticle`](http://schema.org/NewsArticle), [`Person`](http://schema.org/Person), [`Organization`](http://schema.org/Organization), etc.
* `links` - An array of other URLs that represent the same thing that this page represents. For instance, Jane's bio page might include links to Jane's GitHub and Twitter profiles.
### Customizing image output
For most users, setting `image: [path-to-image]` on a per-page basis should be enough. If you need more control over how images are represented, the `image` property can also be an object, with the following options:
* `path` - The relative path to the image. Same as `image: [path-to-image]`
* `twitter` - The relative path to a Twitter-specific image.
* `facebook` - The relative path to a Facebook-specific image.
* `height` - The height of the Facebook (`og:image`) image
* `width` - The width of the Facebook (`og:image`) image
You can use any of the above, optional properties, like so:
```yml
image:
twitter: /img/twitter.png
facebook: /img/facebook.png
height: 100
width: 100
```
### SmartyPants Titles
Titles will be processed using [Jekyll's `smartify` filter](https://jekyllrb.com/docs/templates/). This will use SmartyPants to translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a page title.

View File

@ -1,6 +0,0 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec

33
docs/README.md Normal file
View File

@ -0,0 +1,33 @@
## About Jekyll SEO Tag
A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
[![Gem Version](https://badge.fury.io/rb/jekyll-seo-tag.svg)](https://badge.fury.io/rb/jekyll-seo-tag) [![Build Status](https://travis-ci.org/jekyll/jekyll-seo-tag.svg)](https://travis-ci.org/jekyll/jekyll-seo-tag)
## What it does
Jekyll SEO Tag adds the following meta tags to your site:
* Page title, with site title or description appended
* Page description
* Canonical URL
* Next and previous URLs on paginated pages
* [JSON-LD Site and post metadata](https://developers.google.com/search/docs/guides/intro-structured-data) for richer indexing
* [Open Graph](https://ogp.me/) title, description, site title, and URL (for Facebook, LinkedIn, etc.)
* [Twitter Summary Card](https://dev.twitter.com/cards/overview) metadata
While you could theoretically add the necessary metadata tags yourself, Jekyll SEO Tag provides a battle-tested template of crowdsourced best-practices.
## What it doesn't do
Jekyll SEO tag is designed to output machine-readable metadata for search engines and social networks to index and display. If you're looking for something to analyze your Jekyll site's structure and content (e.g., more traditional SEO optimization), take a look at [The Jekyll SEO Gem](https://github.com/pmarsceill/jekyll-seo-gem).
Jekyll SEO tag isn't designed to accommodate every possible use case. It should work for most site out of the box and without a laundry list of configuration options that serve only to confuse most users.
## Documentation
For more information, see:
* [Installation](installation.md)
* [Usage](usage.md)
* [Advanced usage](advanced-usage.md)

10
docs/_config.yml Normal file
View File

@ -0,0 +1,10 @@
title: Jekyll SEO Tag
description: A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
permalink: pretty
plugins:
- jekyll-seo-tag
- jekyll-sitemap
theme: jekyll-theme-primer

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}" rel="stylesheet">
{% seo %}
</head>
<body>
<div class="container markdown-body">
<h1>{{ site.title }}</h1>
{{ content }}
</div>
<script src="{{ "assets/javascript/anchor-js/anchor.min.js" | relative_url }}"></script>
<script>anchors.add();</script>
</body>
</html>

191
docs/advanced-usage.md Normal file
View File

@ -0,0 +1,191 @@
## Advanced usage
Jekyll SEO Tag is designed to implement SEO best practices by default and to be the right fit for most sites right out of the box. If for some reason, you need more control over the output, read on:
### Disabling `<title>` output
If for some reason, you don't want the plugin to output `<title>` tags on each page, simply invoke the plugin within your template like so:
<!-- {% raw %} -->
```
{% seo title=false %}
```
<!-- {% endraw %} -->
### Author information
Author information is used to propagate the `creator` field of Twitter summary cards. This should be an author-specific, not site-wide Twitter handle (the site-wide username be stored as `site.twitter.username`).
*TL;DR: In most cases, put `author: [your Twitter handle]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.*
There are several ways to convey this author-specific information. Author information is found in the following order of priority:
1. An `author` object, in the documents's front matter, e.g.:
```yml
author:
twitter: benbalter
```
2. An `author` object, in the site's `_config.yml`, e.g.:
```yml
author:
twitter: benbalter
```
3. `site.data.authors[author]`, if an author is specified in the document's front matter, and a corresponding key exists in `site.data.authors`. E.g., you have the following in the document's front matter:
```yml
author: benbalter
```
And you have the following in `_data/authors.yml`:
```yml
benbalter:
picture: /img/benbalter.png
twitter: jekyllrb
potus:
picture: /img/potus.png
twitter: whitehouse
```
In the above example, the author `benbalter`'s Twitter handle will be resolved to `@jekyllrb`. This allows you to centralize author information in a single `_data/authors` file for site with many authors that require more than just the author's username.
*Pro-tip: If `authors` is present in the document's front matter as an array (and `author` is not), the plugin will use the first author listed, as Twitter supports only one author.*
4. An author in the document's front matter (the simplest way), e.g.:
```yml
author: benbalter
```
5. An author in the site's `_config.yml`, e.g.:
```yml
author: benbalter
```
#### Setting author url
Starting from August 6, 2021 [Google recommends](https://developers.google.com/search/updates) to set the `author.url` property. This property helps Google to disambiguate the correct author of the article.
You can set it the same way as the other author properties. For example, you can put it in an `author` object, in the site's `_config.yml`, e.g.:
```yml
author:
name: My Name
url: https://example.com/
```
### Customizing description length
By default, the description is limited to the first 100 words of the full content.
You can adjust this limit at the page level, by using the `seo_description_max_words` page property:
```yml
seo_description_max_words: 200
```
You can also set a default site-wide value for all pages using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/) in your `_config.yml` file:
```yml
defaults:
- scope:
path: ""
values:
seo_description_max_words: 200
```
### Customizing JSON-LD output
The following options can be set for any particular page. While the default options are meant to serve most users in the most common circumstances, there may be situations where more precise control is necessary.
* `seo`
* `name` - If the name of the thing that the page represents is different from the page title. (i.e.: "Frank's Café" vs "Welcome to Frank's Café")
* `type` - The type of things that the page represents. This must be a [Schema.org type](https://schema.org/docs/schemas.html), and will probably usually be something like [`BlogPosting`](https://schema.org/BlogPosting), [`NewsArticle`](https://schema.org/NewsArticle), [`Person`](https://schema.org/Person), [`Organization`](https://schema.org/Organization), etc.
* `links` - An array of other URLs that represent the same thing that this page represents. For instance, Jane's bio page might include links to Jane's GitHub and Twitter profiles.
* `date_modified` - Manually specify the `dateModified` field in the JSON-LD output to override Jekyll's own `dateModified`.
This field will take **first priority** for the `dateModified` JSON-LD output. This is useful when the file timestamp does not match the true time that the content was modified. A user may also install [Last Modified At](https://github.com/gjtorikian/jekyll-last-modified-at) which will offer an alternative way of providing for the `dateModified` field.
### Customizing image output
For most users, setting `image: [path-to-image]` on a per-page basis should be enough. If you need more control over how images are represented, the `image` property can also be an object, with the following options:
* `path` - The relative path to the image. Same as `image: [path-to-image]`
* `height` - The height of the Open Graph (`og:image`) image
* `width` - The width of the Open Graph (`og:image`) image
* `alt` - The alternative image text for Open Graph (`og:image:alt`) and Twitter (`twitter:image:alt`)
You can use any of the above, optional properties, like so:
```yml
image:
path: /img/twitter.png
height: 100
width: 100
alt: Twitter Logo
```
### Setting a default image
You can define a default image using [Front Matter defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/), to provide a default Twitter Card or OGP image to all of your posts and pages.
Here is a very basic example, that you are encouraged to adapt to your needs:
```yml
defaults:
- scope:
path: ""
values:
image: /assets/images/default-card.png
```
### SmartyPants Titles
Titles will be processed using [Jekyll's `smartify` filter](https://jekyllrb.com/docs/liquid/filters/). This will use SmartyPants to translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a page title.
### Setting customized Canonical URL
You can set custom Canonical URL for a page by specifying canonical_url option in page front matter.
E.g., you have the following in the page's front matter:
```yml
layout: post
title: Title of Your Post
canonical_url: 'https://github.com/jekyll/jekyll-seo-tag/'
```
Which will generate canonical_url with specified link in canonical_url.
```html
<link rel="canonical" href="https://github.com/jekyll/jekyll-seo-tag/" />
```
If no canonical_url option was specified, then uses page url for generating canonical_url.
E.g., you have not specified canonical_url in front matter:
```yml
layout: post
title: Title of Your Post
```
Which will generate following canonical_url:
```html
<link rel="canonical" href="https://example.com/title-of-your-post" />
```
### Customizing title modifier for paginated pages
You can override the default title modifier for paginated pages from `Page %{current} of %{total} for ` to a string of your
choice by setting a `seo_paginator_message` key in your `_config.yml`.
For example:
```yml
seo_paginator_message: "%<current>s / %<total>s | "
```
While the value can be any string text, we recommend using a Ruby string-template containing the variables `current` and `total`
similar to the example above, to incorporate the current page-number and total number of paginated pages in the title.

24
docs/installation.md Normal file
View File

@ -0,0 +1,24 @@
# Installing Jekyll SEO Tag
1. Add the following to your site's `Gemfile`:
```ruby
gem 'jekyll-seo-tag'
```
2. Add the following to your site's `_config.yml`:
```yml
plugins:
- jekyll-seo-tag
```
If you are using a Jekyll version less than `3.5.0`, use the `gems` key instead of `plugins`.
3. Add the following right before `</head>` in your site's template(s):
<!-- {% raw %} -->
```liquid
{% seo %}
```
<!-- {% endraw %} -->

81
docs/usage.md Normal file
View File

@ -0,0 +1,81 @@
## Usage
The SEO tag will respect any of the following if included in your site's `_config.yml` (and simply not include them if
they're not defined):
* `title` - Your site's title (e.g., *Ben's Awesome Site*, *The GitHub Blog*, etc.), used as part of the title tag like
`Home | Ben's Awesome Site`.
* `tagline` - A short description (e.g., *A blog dedicated to reviewing cat gifs*), used as part of the title tag like
`Ben's Awesome Site | A blog dedicated to reviewing cat gifs` instead of `Ben's Awesome Site | Long description about a
blog dedicated to reviewing cat gifs` that would be used when `page.title` is not defined.
* `description` - A longer description used for the description meta tag. Also used as fallback for pages that don't
provide their own `description`, and also as part of the page's title tag if neither `page.title` nor `site.tagline`
has been defined.
* `url` - The full URL to your site. Note: `site.github.url` will be used by default.
* `author` - global author information (see [Advanced usage](advanced-usage.md#author-information))
* `twitter` - The following properties are available:
* `twitter:card` - The site's default card type
* `twitter:username` - The site's Twitter handle.
You'll want to describe them like so:
```yml
twitter:
username: benbalter
card: summary
```
* `facebook` - The following properties are available:
* `facebook:app_id` - a Facebook app ID for Facebook insights
* `facebook:publisher` - a Facebook page URL or ID of the publishing entity
* `facebook:admins` - a Facebook user ID for domain insights linked to a personal account
You'll want to describe one or more like so:
```yml
facebook:
app_id: 1234
publisher: 1234
admins: 1234
```
* `logo` - URL to a site-wide logo (e.g., `/assets/your-company-logo.png`) - If you would like the "publisher" property
to be present, you must add this field to your site's configuration, during the validation of the structured data by
Google Search Console, if the `logo` field is not validated, you will find errors inherent to the publisher in the
[Rich Results Testing Tool](https://search.google.com/test/rich-results)
* `social` - For [specifying social profiles](https://developers.google.com/search/docs/guides/enhance-site#add-your-sites-name-logo-and-social-links).
The following properties are available:
* `name` - If the user or organization name differs from the site's name
* `links` - An array of links to social media profiles.
```yml
social:
name: Ben Balter
links:
- https://twitter.com/BenBalter
- https://www.facebook.com/ben.balter
- https://www.linkedin.com/in/BenBalter
- https://github.com/benbalter
- https://keybase.io/benbalter
```
* `google_site_verification` for verifying ownership via Google Search Console
* Alternatively, verify ownership with several services at once using the following format:
```yml
webmaster_verifications:
google: 1234
bing: 1234
alexa: 1234
yandex: 1234
baidu: 1234
facebook: 1234
```
* `locale` - The locale these tags are marked up in. Of the format `language_TERRITORY`. Default is `en_US`. Takes priority
over existing config key `lang`.
The SEO tag will respect the following YAML front matter if included in a post, page, or document:
* `title` - The title of the post, page, or document
* `description` - A short description of the page's content
* `image` - URL to an image associated with the post, page, or document (e.g., `/assets/page-pic.jpg`)
* `author` - Page-, post-, or document-specific author information (see [Advanced usage](advanced-usage.md#author-information))
* `locale` - Page-, post-, or document-specific locale information. Takes priority over existing front matter attribute `lang`.
*Note:* Front matter defaults can be used for any of the above values as described in advanced usage with an image example.

View File

@ -1,34 +1,34 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jekyll-seo-tag/version'
# frozen_string_literal: true
require_relative "lib/jekyll-seo-tag/version"
Gem::Specification.new do |spec|
spec.name = 'jekyll-seo-tag'
spec.name = "jekyll-seo-tag"
spec.version = Jekyll::SeoTag::VERSION
spec.authors = ['Ben Balter']
spec.email = ['ben.balter@github.com']
spec.authors = ["Ben Balter"]
spec.email = ["ben.balter@github.com"]
spec.summary = "A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content."
spec.homepage = 'https://github.com/benbalter/jekyll-seo-tag'
spec.license = 'MIT'
spec.homepage = "https://github.com/jekyll/jekyll-seo-tag"
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
spec.metadata["allowed_push_host"] = "https://rubygems.org"
else
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
end
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.required_ruby_version = ">= 2.5.0"
spec.add_dependency 'jekyll', '~> 3.3'
spec.add_development_dependency 'bundler', '~> 1.10'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.3'
spec.add_development_dependency 'html-proofer', '~> 2.5'
spec.add_development_dependency 'rubocop', '~> 0.37'
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_dependency "jekyll", ">= 3.8", "< 5.0"
spec.add_development_dependency "bundler", ">= 1.15"
spec.add_development_dependency "html-proofer", "~> 3.7"
spec.add_development_dependency "rspec", "~> 3.5"
spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0"
end

View File

@ -1,7 +1,18 @@
# frozen_string_literal: true
require "jekyll"
require "jekyll-seo-tag/version"
module Jekyll
class SeoTag < Liquid::Tag
autoload :JSONLD, "jekyll-seo-tag/json_ld"
autoload :AuthorDrop, "jekyll-seo-tag/author_drop"
autoload :ImageDrop, "jekyll-seo-tag/image_drop"
autoload :JSONLDDrop, "jekyll-seo-tag/json_ld_drop"
autoload :UrlHelper, "jekyll-seo-tag/url_helper"
autoload :Drop, "jekyll-seo-tag/drop"
autoload :Filters, "jekyll-seo-tag/filters"
attr_accessor :context
# Matches all whitespace that follows either
@ -13,7 +24,7 @@ module Jekyll
# We will not strip any whitespace if the next character is a '-'
# so that we do not interfere with the HTML comment at the
# very begining
MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!
MINIFY_REGEX = %r!(?<=[{}]|[>,]\n)\s+(?\!-)!.freeze
def initialize(_tag_name, text, _tokens)
super
@ -22,7 +33,7 @@ module Jekyll
def render(context)
@context = context
template.render!(payload, info)
SeoTag.template.render!(payload, info)
end
private
@ -30,43 +41,51 @@ module Jekyll
def options
{
"version" => Jekyll::SeoTag::VERSION,
"title" => title?
"title" => title?,
}
end
def payload
{
"page" => context.registers[:page],
"site" => context.registers[:site].site_payload["site"],
"paginator" => context["paginator"],
"seo_tag" => options
}
# site_payload is an instance of UnifiedPayloadDrop. See https://github.com/jekyll/jekyll/blob/22f2724a1f117a94cc16d18c499a93d5915ede4f/lib/jekyll/site.rb#L261-L276
context.registers[:site].site_payload.tap do |site_payload|
site_payload["page"] = context.registers[:page]
site_payload["paginator"] = context["paginator"]
site_payload["seo_tag"] = drop
end
end
def title?
!(@text =~ %r!title=false!i)
def drop
if context.registers[:site].liquid_renderer.respond_to?(:cache)
Jekyll::SeoTag::Drop.new(@text, @context)
else
@drop ||= Jekyll::SeoTag::Drop.new(@text, @context)
end
end
def info
{
:registers => context.registers,
:filters => [Jekyll::Filters]
:filters => [Jekyll::Filters],
}
end
def template
@template ||= Liquid::Template.parse template_contents
end
def template_contents
@template_contents ||= begin
File.read(template_path).gsub(MINIFY_REGEX, "")
class << self
def template
@template ||= Liquid::Template.parse template_contents
end
end
def template_path
@template_path ||= begin
File.expand_path "./template.html", File.dirname(__FILE__)
private
def template_contents
@template_contents ||= begin
File.read(template_path).gsub(MINIFY_REGEX, "")
end
end
def template_path
@template_path ||= begin
File.expand_path "./template.html", File.dirname(__FILE__)
end
end
end
end

View File

@ -0,0 +1,93 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
# A drop representing the current page's author
#
# Author name will be pulled from:
#
# 1. The page's `author` key
# 2. The first author in the page's `authors` key
# 3. The `author` key in the site config
#
# If the result from the name search is a string, we'll also check
# for additional author metadata in `site.data.authors`
class AuthorDrop < Jekyll::Drops::Drop
# Initialize a new AuthorDrop
#
# page - The page hash (e.g., Page#to_liquid)
# site - The Jekyll::Drops::SiteDrop
def initialize(page: nil, site: nil)
raise ArgumentError unless page && site
@mutations = {}
@page = page
@site = site
end
# AuthorDrop#to_s should return name, allowing the author drop to safely
# replace `page.author`, if necessary, and remain backwards compatible
def name
author_hash["name"]
end
alias_method :to_s, :name
def twitter
return @twitter if defined? @twitter
twitter = author_hash["twitter"] || author_hash["name"]
@twitter = twitter.is_a?(String) ? twitter.sub(%r!^@!, "") : nil
end
private
attr_reader :site, :page
# Finds the page author in the page.author, page.authors, or site.author
#
# Returns a string or hash representing the author
def resolved_author
return @resolved_author if defined? @resolved_author
sources = [page["author"]]
sources << page["authors"].first if page["authors"].is_a?(Array)
sources << site["author"]
@resolved_author = sources.find { |s| !s.to_s.empty? }
end
# If resolved_author is a string, attempts to find coresponding author
# metadata in `site.data.authors`
#
# Returns a hash representing additional metadata or an empty hash
def site_data_hash
@site_data_hash ||= begin
return {} unless resolved_author.is_a?(String)
return {} unless site.data["authors"].is_a?(Hash)
author_hash = site.data["authors"][resolved_author]
author_hash.is_a?(Hash) ? author_hash : {}
end
end
# Returns the normalized author hash representing the page author,
# including site-wide metadata if the author is provided as a string,
# or an empty hash, if the author cannot be resolved
def author_hash
@author_hash ||= begin
case resolved_author
when Hash
resolved_author
when String
{ "name" => resolved_author }.merge!(site_data_hash)
else
{}
end
end
end
# Since author_hash is aliased to fallback_data, any values in the hash
# will be exposed via the drop, allowing support for arbitrary metadata
alias_method :fallback_data, :author_hash
end
end
end

259
lib/jekyll-seo-tag/drop.rb Normal file
View File

@ -0,0 +1,259 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
class Drop < Jekyll::Drops::Drop
include Jekyll::SeoTag::UrlHelper
TITLE_SEPARATOR = " | "
FORMAT_STRING_METHODS = [
:markdownify, :strip_html, :normalize_whitespace, :escape_once,
].freeze
HOMEPAGE_OR_ABOUT_REGEX = %r!^/(about/)?(index.html?)?$!.freeze
EMPTY_READ_ONLY_HASH = {}.freeze
private_constant :EMPTY_READ_ONLY_HASH
def initialize(text, context)
@obj = EMPTY_READ_ONLY_HASH
@mutations = {}
@text = text
@context = context
end
def version
Jekyll::SeoTag::VERSION
end
# Should the `<title>` tag be generated for this page?
def title?
return false unless title
return @display_title if defined?(@display_title)
@display_title = (@text !~ %r!title=false!i)
end
def site_title
@site_title ||= format_string(site["title"] || site["name"])
end
def site_tagline
@site_tagline ||= format_string site["tagline"]
end
def site_description
@site_description ||= format_string site["description"]
end
# Page title without site title or description appended
def page_title
@page_title ||= format_string(page["title"]) || site_title
end
def site_tagline_or_description
site_tagline || site_description
end
# Page title with site title or description appended
# rubocop:disable Metrics/CyclomaticComplexity
def title
@title ||= begin
if site_title && page_title != site_title
page_title + TITLE_SEPARATOR + site_title
elsif site_description && site_title
site_title + TITLE_SEPARATOR + site_tagline_or_description
else
page_title || site_title
end
end
return page_number + @title if page_number
@title
end
# rubocop:enable Metrics/CyclomaticComplexity
def name
return @name if defined?(@name)
@name = if seo_name
seo_name
elsif !homepage_or_about?
nil
elsif site_social["name"]
format_string site_social["name"]
elsif site_title
site_title
end
end
def description
@description ||= begin
value = format_string(page["description"] || page["excerpt"]) || site_description
snippet(value, description_max_words)
end
end
# A drop representing the page author
def author
@author ||= AuthorDrop.new(:page => page, :site => site)
end
# A drop representing the JSON-LD output
def json_ld
@json_ld ||= JSONLDDrop.new(self)
end
# Returns a Drop representing the page's image
# Returns nil if the image has no path, to preserve backwards compatability
def image
@image ||= ImageDrop.new(:page => page, :context => @context)
@image if @image.path
end
def date_modified
@date_modified ||= begin
date = page_seo["date_modified"] || page["last_modified_at"].to_liquid || page["date"]
filters.date_to_xmlschema(date) if date
end
end
def date_published
@date_published ||= filters.date_to_xmlschema(page["date"]) if page["date"]
end
def type
@type ||= begin
if page_seo["type"]
page_seo["type"]
elsif homepage_or_about?
"WebSite"
elsif page["date"]
"BlogPosting"
else
"WebPage"
end
end
end
def links
@links ||= begin
if page_seo["links"]
page_seo["links"]
elsif homepage_or_about? && site_social["links"]
site_social["links"]
end
end
end
def logo
@logo ||= begin
return unless site["logo"]
if absolute_url? site["logo"]
filters.uri_escape site["logo"]
else
filters.uri_escape filters.absolute_url site["logo"]
end
end
end
def page_lang
@page_lang ||= page["lang"] || site["lang"] || "en_US"
end
def page_locale
@page_locale ||= (page["locale"] || site["locale"] || page_lang).tr("-", "_")
end
def canonical_url
@canonical_url ||= begin
if page["canonical_url"].to_s.empty?
filters.absolute_url(page["url"]).to_s.gsub(%r!/index\.html$!, "/")
else
page["canonical_url"]
end
end
end
def description_max_words
@description_max_words ||= page["seo_description_max_words"] || 100
end
private
def filters
@filters ||= Jekyll::SeoTag::Filters.new(@context)
end
def page
@page ||= @context.registers[:page].to_liquid
end
def site
@site ||= @context.registers[:site].site_payload["site"].to_liquid
end
def homepage_or_about?
page["url"] =~ HOMEPAGE_OR_ABOUT_REGEX
end
def page_number
return unless @context["paginator"] && @context["paginator"]["page"]
current = @context["paginator"]["page"]
total = @context["paginator"]["total_pages"]
paginator_message = site["seo_paginator_message"] || "Page %<current>s of %<total>s for "
format(paginator_message, :current => current, :total => total) if current > 1
end
attr_reader :context
def fallback_data
@fallback_data ||= {}
end
def format_string(string)
string = FORMAT_STRING_METHODS.reduce(string) do |memo, method|
filters.public_send(method, memo)
end
string unless string.empty?
end
def snippet(string, max_words)
return string if string.nil?
result = string.split(%r!\s+!, max_words + 1)[0...max_words].join(" ")
result.length < string.length ? result.concat("") : result
end
def seo_name
@seo_name ||= format_string(page_seo["name"]) if page_seo["name"]
end
def page_seo
@page_seo ||= sub_hash(page, "seo")
end
def site_social
@site_social ||= sub_hash(site, "social")
end
# Safely returns a sub hash
#
# hash - the parent hash
# key - the key in the parent hash
#
# Returns the sub hash or an empty hash, if it does not exist
def sub_hash(hash, key)
if hash[key].is_a?(Hash)
hash[key]
else
EMPTY_READ_ONLY_HASH
end
end
end
end
end

View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
class Filters
include Jekyll::Filters
include Liquid::StandardFilters
def initialize(context)
@context = context
end
end
end
end

View File

@ -0,0 +1,83 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
# A drop representing the page image
# The image path will be pulled from:
#
# 1. The `image` key if it's a string
# 2. The `image.path` key if it's a hash
# 3. The `image.facebook` key
# 4. The `image.twitter` key
class ImageDrop < Jekyll::Drops::Drop
include Jekyll::SeoTag::UrlHelper
# Initialize a new ImageDrop
#
# page - The page hash (e.g., Page#to_liquid)
# context - the Liquid::Context
def initialize(page: nil, context: nil)
raise ArgumentError unless page && context
@mutations = {}
@page = page
@context = context
end
# Called path for backwards compatability, this is really
# the escaped, absolute URL representing the page's image
# Returns nil if no image path can be determined
def path
@path ||= filters.uri_escape(absolute_url) if absolute_url
end
alias_method :to_s, :path
private
attr_accessor :page, :context
# The normalized image hash with a `path` key (which may be nil)
def image_hash
@image_hash ||= begin
image_meta = page["image"]
case image_meta
when Hash
{ "path" => nil }.merge!(image_meta)
when String
{ "path" => image_meta }
else
{ "path" => nil }
end
end
end
alias_method :fallback_data, :image_hash
def raw_path
@raw_path ||= begin
image_hash["path"] || image_hash["facebook"] || image_hash["twitter"]
end
end
def absolute_url
return unless raw_path
@absolute_url ||= build_absolute_path
end
def build_absolute_path
return raw_path unless raw_path.is_a?(String) && absolute_url?(raw_path) == false
return filters.absolute_url(raw_path) if raw_path.start_with?("/")
page_dir = @page["url"]
page_dir = File.dirname(page_dir) unless page_dir.end_with?("/")
filters.absolute_url File.join(page_dir, raw_path)
end
def filters
@filters ||= Jekyll::SeoTag::Filters.new(context)
end
end
end
end

View File

@ -0,0 +1,31 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
# This module is deprecated, but is included in the Gem to avoid a breaking
# change and should be removed at the next major version bump
module JSONLD
METHODS_KEYS = {
:json_context => "@context",
:type => "@type",
:name => "name",
:page_title => "headline",
:json_author => "author",
:json_image => "image",
:date_published => "datePublished",
:date_modified => "dateModified",
:description => "description",
:publisher => "publisher",
:main_entity => "mainEntityOfPage",
:links => "sameAs",
:canonical_url => "url",
}.freeze
# Self should be a Jekyll::SeoTag::Drop instance (when extending the module)
def json_ld
Jekyll.logger.warn "Jekyll::SeoTag::JSONLD is deprecated"
@json_ld ||= JSONLDDrop.new(self)
end
end
end
end

View File

@ -0,0 +1,104 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
class JSONLDDrop < Jekyll::Drops::Drop
extend Forwardable
def_delegator :page_drop, :name, :name
def_delegator :page_drop, :description, :description
def_delegator :page_drop, :canonical_url, :url
def_delegator :page_drop, :page_title, :headline
def_delegator :page_drop, :date_modified, :dateModified
def_delegator :page_drop, :date_published, :datePublished
def_delegator :page_drop, :links, :sameAs
def_delegator :page_drop, :logo, :logo
def_delegator :page_drop, :type, :type
# Expose #type and #logo as private methods and #@type as a public method
alias_method :@type, :type
private :type, :logo
VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze
VALID_AUTHOR_TYPES = %w(Organization Person).freeze
private_constant :VALID_ENTITY_TYPES, :VALID_AUTHOR_TYPES
# page_drop should be an instance of Jekyll::SeoTag::Drop
def initialize(page_drop)
@mutations = {}
@page_drop = page_drop
end
def fallback_data
@fallback_data ||= {
"@context" => "https://schema.org",
}
end
def author
return unless page_drop.author["name"]
author_type = page_drop.author["type"]
return if author_type && !VALID_AUTHOR_TYPES.include?(author_type)
hash = {
"@type" => author_type || "Person",
"name" => page_drop.author["name"],
}
author_url = page_drop.author["url"]
hash["url"] = author_url if author_url
hash
end
def image
return unless page_drop.image
return page_drop.image.path if page_drop.image.keys.length == 1
hash = page_drop.image.to_h
hash["url"] = hash.delete("path")
hash["@type"] = "imageObject"
hash
end
def publisher
return unless logo
output = {
"@type" => "Organization",
"logo" => {
"@type" => "ImageObject",
"url" => logo,
},
}
output["name"] = page_drop.author.name if page_drop.author.name
output
end
def main_entity
return unless VALID_ENTITY_TYPES.include?(type)
{
"@type" => "WebPage",
"@id" => page_drop.canonical_url,
}
end
alias_method :mainEntityOfPage, :main_entity
private :main_entity
# Returns a JSON-encoded object containing the JSON-LD data.
# Keys are sorted.
def to_json(state = nil)
keys.sort.each_with_object({}) do |(key, _), result|
v = self[key]
result[key] = v unless v.nil?
end.to_json(state)
end
private
attr_reader :page_drop
end
end
end

View File

@ -0,0 +1,23 @@
# frozen_string_literal: true
module Jekyll
class SeoTag
# Mixin to share common URL-related methods between class
module UrlHelper
private
# Determines if the given string is an absolute URL
#
# Returns true if an absolute URL
# Returns false if it's a relative URL
# Returns nil if it is not a string or can't be parsed as a URL
def absolute_url?(string)
return unless string
Addressable::URI.parse(string).absolute?
rescue Addressable::URI::InvalidURIError
nil
end
end
end
end

View File

@ -1,8 +1,10 @@
# frozen_string_literal: true
# Prevent bundler errors
module Liquid; class Tag; end; end
module Jekyll
class SeoTag < Liquid::Tag
VERSION = "2.0.0".freeze
VERSION = "2.8.0"
end
end

256
lib/template.html Normal file → Executable file
View File

@ -1,160 +1,82 @@
<!-- Begin Jekyll SEO tag v{{ seo_tag.version }} -->
{% if page.url == "/" or page.url == "/about/" %}
{% assign seo_homepage_or_about = true %}
{% if seo_tag.title? %}
<title>{{ seo_tag.title }}</title>
{% endif %}
{% assign seo_site_title = site.title | default: site.name %}
<meta name="generator" content="Jekyll v{{ jekyll.version }}" />
{% if page.title %}
{% assign seo_title = page.title %}
{% assign seo_page_title = page.title %}
{% if seo_tag.page_title %}
<meta property="og:title" content="{{ seo_tag.page_title }}" />
{% endif %}
{% if seo_site_title %}
{% assign seo_title = seo_title | append:" - " | append: seo_site_title %}
{% if seo_tag.author.name %}
<meta name="author" content="{{ seo_tag.author.name }}" />
{% endif %}
<meta property="og:locale" content="{{ seo_tag.page_locale }}" />
{% if seo_tag.description %}
<meta name="description" content="{{ seo_tag.description }}" />
<meta property="og:description" content="{{ seo_tag.description }}" />
<meta property="twitter:description" content="{{ seo_tag.description }}" />
{% endif %}
{% if site.url %}
<link rel="canonical" href="{{ seo_tag.canonical_url }}" />
<meta property="og:url" content="{{ seo_tag.canonical_url }}" />
{% endif %}
{% if seo_tag.site_title %}
<meta property="og:site_name" content="{{ seo_tag.site_title }}" />
{% endif %}
{% if seo_tag.image %}
<meta property="og:image" content="{{ seo_tag.image.path }}" />
{% if seo_tag.image.height %}
<meta property="og:image:height" content="{{ seo_tag.image.height }}" />
{% endif %}
{% elsif seo_site_title %}
{% assign seo_title = seo_site_title %}
{% assign seo_page_title = seo_site_title %}
{% if site.description %}
{% assign seo_title = seo_title | append:" - " | append: site.description %}
{% if seo_tag.image.width %}
<meta property="og:image:width" content="{{ seo_tag.image.width }}" />
{% endif %}
{% endif %}
{% if page.seo and page.seo.name %}
{% assign seo_name = page.seo.name %}
{% elsif seo_homepage_or_about and site.social and site.social.name %}
{% assign seo_name = site.social.name %}
{% elsif seo_homepage_or_about and seo_site_title %}
{% assign seo_name = seo_site_title %}
{% endif %}
{% if seo_name %}
{% assign seo_name = seo_name | smartify | strip_html | strip_newlines | escape_once %}
{% endif %}
{% if seo_title %}
{% assign seo_title = seo_title | smartify | strip_html | strip_newlines | escape_once %}
{% endif %}
{% if seo_site_title %}
{% assign seo_site_title = seo_site_title | smartify | strip_html | strip_newlines | escape_once %}
{% endif %}
{% if seo_page_title %}
{% assign seo_page_title = seo_page_title | smartify | strip_html | strip_newlines | escape_once %}
{% endif %}
{% assign seo_description = page.description | default: page.excerpt | default: site.description %}
{% if seo_description %}
{% assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once %}
{% endif %}
{% assign seo_author = page.author | default: page.authors[0] | default: site.author %}
{% if seo_author %}
{% if seo_author.twitter %}
{% assign seo_author_twitter = seo_author.twitter %}
{% else %}
{% if site.data.authors and site.data.authors[seo_author] %}
{% assign seo_author_twitter = site.data.authors[seo_author].twitter %}
{% else %}
{% assign seo_author_twitter = seo_author %}
{% endif %}
{% if seo_tag.image.alt %}
<meta property="og:image:alt" content="{{ seo_tag.image.alt }}" />
{% endif %}
{% assign seo_author_twitter = seo_author_twitter | replace:"@","" %}
{% endif %}
{% if page.seo and page.seo.type %}
{% assign seo_type = page.seo.type %}
{% elsif seo_homepage_or_about %}
{% assign seo_type = "WebSite" %}
{% elsif page.date %}
{% assign seo_type = "BlogPosting" %}
{% else %}
{% assign seo_type = "WebPage" %}
{% endif %}
{% if page.seo and page.seo.links %}
{% assign seo_links = page.seo.links %}
{% elsif seo_homepage_or_about and site.social and site.social.links %}
{% assign seo_links = site.social.links %}
{% endif %}
{% if site.logo %}
{% assign seo_site_logo = site.logo %}
{% unless seo_site_logo contains "://" %}
{% assign seo_site_logo = seo_site_logo | absolute_url %}
{% endunless %}
{% assign seo_site_logo = seo_site_logo | escape %}
{% endif %}
{% if page.image %}
{% assign seo_page_image = page.image.path | default: page.image.facebook | default: page.image %}
{% unless seo_page_image contains "://" %}
{% assign seo_page_image = seo_page_image | absolute_url %}
{% endunless %}
{% assign seo_page_image = seo_page_image | escape %}
{% endif %}
{% if seo_tag.title and seo_title %}
<title>{{ seo_title }}</title>
{% endif %}
{% if seo_page_title %}
<meta property="og:title" content="{{ seo_page_title }}" />
{% endif %}
{% if seo_description %}
<meta name="description" content="{{ seo_description }}" />
<meta property="og:description" content="{{ seo_description }}" />
{% endif %}
{% if page.url %}
<link rel="canonical" href="{{ page.url | replace:'/index.html','/' | absolute_url }}" />
<meta property="og:url" content="{{ page.url | replace:'/index.html','/' | absolute_url }}" />
{% endif %}
{% if seo_site_title %}
<meta property="og:site_name" content="{{ seo_site_title }}" />
{% endif %}
{% if seo_page_image %}
<meta property="og:image" content="{{ seo_page_image }}" />
{% if page.image.height %}
<meta property="og:image:height" content="{{ page.image.height }}" />
{% endif %}
{% if page.image.width %}
<meta property="og:image:width" content="{{ page.image.width }}" />
{% endif %}
{% endif %}
{% if page.image.twitter %}
<meta name="twitter:image" content="{{ page.image.twitter | absolute_url }}" />
{% endif %}
{% if page.date %}
<meta property="og:type" content="article" />
<meta property="article:published_time" content="{{ page.date | date_to_xmlschema }}" />
{% else %}
<meta property="og:type" content="website" />
{% endif %}
{% if paginator.previous_page %}
<link rel="prev" href="{{ paginator.previous_page_path | absolute_url }}">
<link rel="prev" href="{{ paginator.previous_page_path | absolute_url }}" />
{% endif %}
{% if paginator.next_page %}
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}">
<link rel="next" href="{{ paginator.next_page_path | absolute_url }}" />
{% endif %}
{% if seo_tag.image %}
<meta name="twitter:card" content="{{ page.twitter.card | default: site.twitter.card | default: "summary_large_image" }}" />
<meta property="twitter:image" content="{{ seo_tag.image.path }}" />
{% else %}
<meta name="twitter:card" content="summary" />
{% endif %}
{% if seo_tag.image.alt %}
<meta name="twitter:image:alt" content="{{ seo_tag.image.alt }}" />
{% endif %}
{% if seo_tag.page_title %}
<meta property="twitter:title" content="{{ seo_tag.page_title }}" />
{% endif %}
{% if site.twitter %}
{% if seo_page_image or page.image.twitter %}
<meta name="twitter:card" content="summary_large_image" />
{% else %}
<meta name="twitter:card" content="summary" />
{% endif %}
<meta name="twitter:site" content="@{{ site.twitter.username | remove:'@' }}" />
<meta name="twitter:site" content="@{{ site.twitter.username | replace:"@","" }}" />
{% if seo_author_twitter %}
<meta name="twitter:creator" content="@{{ seo_author_twitter }}" />
{% if seo_tag.author.twitter %}
<meta name="twitter:creator" content="@{{ seo_tag.author.twitter | remove:'@' }}" />
{% endif %}
{% endif %}
@ -172,48 +94,36 @@
{% endif %}
{% endif %}
{% if site.google_site_verification %}
{% if site.webmaster_verifications %}
{% if site.webmaster_verifications.google %}
<meta name="google-site-verification" content="{{ site.webmaster_verifications.google }}" />
{% endif %}
{% if site.webmaster_verifications.bing %}
<meta name="msvalidate.01" content="{{ site.webmaster_verifications.bing }}" />
{% endif %}
{% if site.webmaster_verifications.alexa %}
<meta name="alexaVerifyID" content="{{ site.webmaster_verifications.alexa }}" />
{% endif %}
{% if site.webmaster_verifications.yandex %}
<meta name="yandex-verification" content="{{ site.webmaster_verifications.yandex }}" />
{% endif %}
{% if site.webmaster_verifications.baidu %}
<meta name="baidu-site-verification" content="{{ site.webmaster_verifications.baidu }}" />
{% endif %}
{% if site.webmaster_verifications.facebook %}
<meta name="facebook-domain-verification" content="{{ site.webmaster_verifications.facebook }}" />
{% endif %}
{% elsif site.google_site_verification %}
<meta name="google-site-verification" content="{{ site.google_site_verification }}" />
{% endif %}
<script type="application/ld+json">
{
"@context": "http://schema.org",
{% if seo_type %}
"@type": {{ seo_type | jsonify }},
{% endif %}
{% if seo_name %}
"name": {{ seo_name | jsonify }},
{% endif %}
{% if seo_page_title %}
"headline": {{ seo_page_title | jsonify }},
{% endif %}
{% if seo_page_image %}
"image": {{ seo_page_image | jsonify }},
{% endif %}
{% if page.date %}
"datePublished": {{ page.date | date_to_xmlschema | jsonify }},
{% endif %}
{% if seo_description %}
"description": {{ seo_description | jsonify }},
{% endif %}
{% if seo_site_logo %}
"logo": {{ seo_site_logo | jsonify }},
{% endif %}
{% if seo_links %}
"sameAs": {{ seo_links | jsonify }},
{% endif %}
"url": {{ page.url | replace:'/index.html','/' | absolute_url | jsonify }}
}
{{ seo_tag.json_ld | jsonify }}
</script>
<!-- End Jekyll SEO tag -->

View File

@ -2,6 +2,6 @@
set -ex
bundle exec rake spec
bundle exec rspec
bundle exec rubocop -S -D
bundle exec gem build jekyll-seo-tag.gemspec

3
script/site Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
bundle exec jekyll serve --source docs

6
spec/fixtures/_posts/2017-01-03-.md vendored Normal file
View File

@ -0,0 +1,6 @@
---
---
# A post without a title
*See* https://github.com/jekyll/jekyll-seo-tag/commit/4f80ea50b773d1995985e35a8a63806516c353c4#commitcomment-22010563

View File

@ -0,0 +1,164 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag::AuthorDrop do
let(:data) { {} }
let(:config) { { "author" => "site_author" } }
let(:site) do
site = make_site(config)
site.data = data
site
end
let(:site_payload) { site.site_payload["site"] }
let(:name) { "foo" }
let(:twitter) { "foo" }
let(:picture) { nil }
let(:expected_hash) do
{
"name" => name,
"twitter" => twitter,
}
end
let(:page_meta) { { "title" => "page title" } }
let(:page) { make_page(page_meta) }
subject { described_class.new(:page => page.to_liquid, :site => site_payload.to_liquid) }
before do
Jekyll.logger.log_level = :error
end
it "returns the author's name for #to_s" do
expect(subject.to_s).to eql("site_author")
end
context "with site.authors as an array" do
let("data") { { "authors" => %w(foo bar) } }
let(:page_meta) { { "author" => "foo" } }
it "doesn't error" do
expect(subject.to_h).to eql(expected_hash)
end
end
context "with site.authors[author] as string" do
let("data") { { "authors" => { "foo" => "bar" } } }
let(:page_meta) { { "author" => "foo" } }
it "doesn't error" do
expect(subject.to_h).to eql(expected_hash)
end
end
[:with, :without].each do |site_data_type|
context "#{site_data_type} site.author data" do
let(:data) do
if site_data_type == :with
{
"authors" => {
"author" => { "name" => "data_author", "image" => "author.png" },
"array_author" => { "image" => "author.png" },
"string_author" => { "image" => "author.png" },
"site_author" => { "image" => "author.png" },
},
}
else
{}
end
end
{
:string => { "author" => "string_author" },
:array => { "authors" => %w(array_author author2) },
:empty_string => { "author" => "" },
:nil => { "author" => nil },
:hash => { "author" => { "name" => "hash_author" } },
}.each do |author_type, data|
context "with author as #{author_type}" do
let(:page_meta) { data }
let(:expected_author) do
"#{author_type}_author".sub("nil_", "site_").sub("empty_string_", "site_")
end
it "returns the name" do
expect(subject["name"]).to eql(expected_author)
end
it "returns the twitter handle" do
expect(subject["twitter"]).to eql(expected_author)
end
if site_data_type == :with && author_type != :hash
it "returns arbitrary metadata" do
expect(subject["image"]).to eql("author.png")
end
end
end
end
end
end
context "with author as a front matter default" do
let(:config) do
{
"defaults" => [
{
"scope" => { "path" => "" },
"values" => { "author" => "front matter default" },
},
],
}
end
it "uses the author from the front matter default" do
expect(subject["name"]).to eql("front matter default")
end
end
context "twitter" do
let(:page_meta) { { "author" => "author" } }
it "pulls the handle from the author" do
expect(subject["twitter"]).to eql("author")
end
context "with an @" do
let(:page_meta) do
{
"author" => {
"name" => "author",
"twitter" => "@twitter",
},
}
end
it "strips the @" do
expect(subject["twitter"]).to eql("twitter")
end
end
# See https://github.com/jekyll/jekyll-seo-tag/issues/202
context "without an author name or handle" do
let(:page_meta) { { "author" => { "foo" => "bar" } } }
it "dosen't blow up" do
expect(subject["twitter"]).to be_nil
end
end
context "with an explicit handle" do
let(:page_meta) do
{
"author" => {
"name" => "author",
"twitter" => "twitter",
},
}
end
it "pulls the handle from the hash" do
expect(subject["twitter"]).to eql("twitter")
end
end
end
end

View File

@ -0,0 +1,538 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag::Drop do
let(:config) { { "title" => "site title" } }
let(:page_meta) { { "title" => "page title" } }
let(:page) { make_page(page_meta) }
let(:site) { make_site(config) }
let(:context) { make_context(:page => page, :site => site) }
let(:text) { "" }
subject { described_class.new(text, context) }
before do
Jekyll.logger.log_level = :error
end
# Drop includes liquid filters which expect arguments
# By default, in drops, `to_h` will call each public method with no arugments
# Here, that would cause the filters to explode. This test ensures that all
# public methods don't explode when called without arguments. Don't explode.
it "doesn't blow up on to_h" do
expect { subject.to_h }.to_not raise_error
end
it "returns the version" do
expect(subject.version).to eql(Jekyll::SeoTag::VERSION)
end
context "title?" do
it "knows to include the title" do
expect(subject.title?).to be_truthy
end
context "with title=false" do
let(:text) { "title=false" }
it "knows not to include the title" do
expect(subject.title?).to be_falsy
end
end
context "site title" do
it "knows the site title" do
expect(subject.site_title).to eql("site title")
end
context "with site.name" do
let(:config) { { "name" => "site title" } }
it "knows the site title" do
expect(subject.site_title).to eql("site title")
end
end
end
context "page title" do
it "knows the page title" do
expect(subject.page_title).to eql("page title")
end
context "without a page title" do
let(:page) { make_page }
it "knows the page title" do
expect(subject.page_title).to eql("site title")
end
end
end
context "title" do
context "with a page and site title" do
it "builds the title" do
expect(subject.title).to eql("page title | site title")
end
end
context "with a site description but no page title" do
let(:page) { make_page }
let(:config) do
{ "title" => "site title", "description" => "site description" }
end
it "builds the title" do
expect(subject.title).to eql("site title | site description")
end
end
context "with a site tagline but no page title" do
let(:page) { make_page }
let(:config) do
{ "title" => "site title", "description" => "site description", "tagline" => "site tagline" }
end
it "builds the title" do
expect(subject.title).to eql("site title | site tagline")
end
end
context "with just a page title" do
let(:site) { make_site }
it "builds the title" do
expect(subject.title).to eql("page title")
end
end
context "with just a site title" do
let(:page) { make_page }
it "builds the title" do
expect(subject.title).to eql("site title")
end
end
context "without a page or site title" do
let(:page) { make_page }
let(:site) { make_site }
it "returns nil" do
expect(subject.title).to be_nil
end
end
context "with an empty page title" do
let(:page_meta) { { :title => "" } }
it "builds the title" do
expect(subject.title).to eql("site title")
end
end
context "with an empty site title" do
let(:config) { { :title => "" } }
it "builds the title" do
expect(subject.title).to eql("page title")
end
end
context "with an empty page and site title" do
let(:page_meta) { { :title => "" } }
let(:config) { { :title => "" } }
it "returns nil" do
expect(subject.title).to be_nil
end
end
end
end
context "name" do
context "with seo.name" do
let(:page_meta) do
{ "seo" => { "name" => "seo name" } }
end
it "uses the seo name" do
expect(subject.name).to eql("seo name")
end
end
context "the index" do
let(:page_meta) { { "permalink" => "/" } }
context "with site.social.name" do
let(:config) { { "social" => { "name" => "social name" } } }
it "uses site.social.name" do
expect(subject.name).to eql("social name")
end
end
context "with site.social as an array" do
let(:config) { { "social" => %w(a b) } }
it "uses site.social.name" do
expect(subject.name).to be_nil
end
end
it "uses the site title" do
expect(subject.name).to eql("site title")
end
end
context "site description" do
context "with a site description" do
let(:config) { { :description => "site description " } }
it "returns the site discription" do
expect(subject.site_description).to eql("site description")
end
end
context "without a site description" do
let(:site) { make_site }
it "returns nil" do
expect(subject.site_description).to be_nil
end
end
end
context "page description" do
context "with a page description" do
let(:page_meta) { { "description"=> "page description" } }
it "uses the page description" do
expect(subject.description).to eql("page description")
end
end
context "with a page excerpt" do
let(:page_meta) { { "description"=> "page excerpt" } }
it "uses the page description" do
expect(subject.description).to eql("page excerpt")
end
end
context "with a site description" do
let(:config) { { "description"=> "site description" } }
it "uses the page description" do
expect(subject.description).to eql("site description")
end
end
context "with no descriptions" do
let(:page_meta) { { "description" => nil, "excerpt" => nil } }
let(:config) { { "description"=> nil } }
it "uses returns nil" do
expect(subject.description).to be_nil
end
end
context "truncation" do
context "without seo_description_max_words" do
let(:page_meta) { { "description" => "word " * 150 } }
it "truncates the description to the first 200 words" do
expect(subject.description).to eql(("word " * 100).chop.concat(""))
end
end
context "with an explicit seo_description_max_words property" do
let(:page_meta) { { "description" => "For a long time, I went to bed early", "seo_description_max_words" => 6 } }
it "truncates the description to the configured words count" do
expect(subject.description).to eql("For a long time, I went…")
end
end
end
end
context "author" do
let(:page_meta) { { "author" => "foo" } }
it "returns an AuthorDrop" do
expect(subject.author).to be_a(Jekyll::SeoTag::AuthorDrop)
end
it "passes page information" do
expect(subject.author.name).to eql("foo")
end
# Regression test to ensure to_liquid is called on site and page
# before being passed to AuthorDrop
context "with author as a front matter default" do
let(:page_meta) { {} }
let(:config) do
{
"defaults" => [
{
"scope" => { "path" => "" },
"values" => { "author" => "front matter default" },
},
],
}
end
it "uses the author from the front matter default" do
expect(subject.author["name"]).to eql("front matter default")
end
end
end
end
context "date published" do
let(:config) { { "timezone" => "America/New_York" } }
let(:page_meta) { { "date" => "2017-01-01" } }
it "uses page.date" do
expect(subject.date_published).to eql("2017-01-01T00:00:00-05:00")
end
end
context "date modified" do
let(:config) { { "timezone" => "America/New_York" } }
context "with seo.date_modified" do
let(:page_meta) { { "seo" => { "date_modified" => "2017-01-01" } } }
it "uses seo.date_modified" do
expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00")
end
end
context "with page.last_modified_at" do
let(:page_meta) { { "last_modified_at" => "2017-01-01" } }
it "uses page.last_modified_at" do
expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00")
end
end
context "date" do
let(:page_meta) { { "date" => "2017-01-01" } }
it "uses page.date" do
expect(subject.date_modified).to eql("2017-01-01T00:00:00-05:00")
end
end
end
context "type" do
context "with seo.type set" do
let(:page_meta) { { "seo" => { "type" => "test" } } }
it "uses seo.type" do
expect(subject.type).to eql("test")
end
end
context "with seo as an array" do
let(:page_meta) { { "seo" => %w(a b) } }
it "uses seo.type" do
expect(subject.type).to eql("WebPage")
end
end
context "the homepage" do
let(:page_meta) { { "permalink" => "/" } }
it "is a website" do
expect(subject.type).to eql("WebSite")
end
end
context "the about page" do
let(:page) { make_page("permalink" => "/about/") }
it "is a website" do
expect(subject.type).to eql("WebSite")
end
end
context "a blog post" do
let(:page_meta) { { "date" => "2017-01-01" } }
it "is a blog post" do
expect(subject.type).to eql("BlogPosting")
end
end
it "is a webpage" do
expect(subject.type).to eql("WebPage")
end
end
context "links" do
context "with seo.links" do
let(:page_meta) { { "seo" => { "links" => %w(foo bar) } } }
it "uses seo.links" do
expect(subject.links).to eql(%w(foo bar))
end
end
context "with site.social.links" do
let(:config) { { "social" => { "links"=> %w(a b) } } }
it "doesn't use site.social.links" do
expect(subject.links).to be_nil
end
context "the homepage" do
let(:page_meta) { { "permalink" => "/" } }
it "uses site.social.links" do
expect(subject.links).to eql(%w(a b))
end
end
end
end
context "logo" do
context "without site.logo" do
it "returns nothing" do
expect(subject.logo).to be_nil
end
end
context "with an absolute site.logo" do
let(:config) { { "logo" => "http://example.com/image.png" } }
it "uses site.logo" do
expect(subject.logo).to eql("http://example.com/image.png")
end
end
context "with a relative site.logo" do
let(:config) do
{
"logo" => "image.png",
"url" => "http://example.com",
}
end
it "uses site.logo" do
expect(subject.logo).to eql("http://example.com/image.png")
end
end
context "with a uri-escaped logo" do
let(:config) { { "logo" => "some image.png" } }
it "escapes the logo" do
expect(subject.logo).to eql("/some%20image.png")
end
end
end
context "image" do
let(:image) { "/foo.png" }
let(:page_meta) { { "image" => image } }
it "returns a Drop" do
expect(subject.image).to be_a(Jekyll::SeoTag::ImageDrop)
end
it "returns the image" do
expect(subject.image["path"]).to eql("/foo.png")
end
end
context "lang" do
context "with page.lang" do
let(:page_meta) { { "lang" => "en_GB" } }
it "uses page.lang" do
expect(subject.page_lang).to eql("en_GB")
end
end
context "with site.lang" do
let(:config) { { "lang" => "en_GB" } }
it "uses site.lang" do
expect(subject.page_lang).to eql("en_GB")
end
end
context "with nothing" do
it "defaults" do
expect(subject.page_lang).to eql("en_US")
end
end
end
context "homepage_or_about?" do
[
"/", "/index.html", "index.html", "/index.htm",
"/about/", "/about/index.html",
].each do |permalink|
context "when passed '#{permalink}' as a permalink" do
let(:page_meta) { { "permalink" => permalink } }
it "knows it's the home or about page" do
expect(subject.send(:homepage_or_about?)).to be_truthy
end
end
end
context "a random URL" do
let(:page_meta) { { "permalink" => "/about-foo/" } }
it "knows it's not the home or about page" do
expect(subject.send(:homepage_or_about?)).to be_falsy
end
end
end
context "canonical url" do
let(:config) { { :url => "http://example.com" } }
context "when canonical url is specified for a page" do
let(:canonical_url) { "https://github.com/jekyll/jekyll-seo-tag/" }
let(:page_meta) { { "title" => "page title", "canonical_url" => canonical_url } }
it "uses specified canonical url" do
expect(subject.canonical_url).to eq(canonical_url)
end
end
context "when canonical url is not specified for a page" do
it "uses site specific canonical url" do
expect(subject.canonical_url).to eq("http://example.com/page.html")
end
end
end
context "pagination" do
let(:context) do
make_context(
{ :page => page, :site => site },
"paginator" => { "page" => 2, "total_pages" => 10 }
)
end
it "render default pagination title" do
expect(subject.send(:page_number)).to eq("Page 2 of 10 for ")
end
context "render custom pagination title" do
let(:config) { { "seo_paginator_message" => "%<current>s of %<total>s" } }
it "renders the correct page number" do
expect(subject.send(:page_number)).to eq("2 of 10")
end
end
end
it "exposes the JSON-LD drop" do
expect(subject.json_ld).to be_a(Jekyll::SeoTag::JSONLDDrop)
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag::Filters do
let(:page) { make_page }
let(:site) { make_site }
let(:context) { make_context(:page => page, :site => site) }
subject { described_class.new(context) }
before do
Jekyll.logger.log_level = :error
end
it "stores the context" do
expect(subject.instance_variable_get("@context")).to be_a(Liquid::Context)
end
it "exposes jekyll filters" do
expect(subject).to respond_to(:markdownify)
end
it "exposes liquid standard filters" do
expect(subject).to respond_to(:normalize_whitespace)
end
end

View File

@ -0,0 +1,121 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag::ImageDrop do
let(:config) { { "title" => "site title" } }
let(:image) { nil }
let(:page_meta) { { "image" => image, "dir" => "foo" } }
let(:page) { make_page(page_meta) }
let(:site) { make_site(config) }
let(:context) { make_context(:page => page, :site => site) }
let(:text) { "" }
subject { described_class.new(:page => page.to_liquid, :context => context) }
before do
Jekyll.logger.log_level = :error
end
context "with a post object" do
let(:image) { "image.png" }
let(:page_meta) { { "image" => image, "date" => "2017-01-01" } }
let(:page) { make_post(page_meta) }
it "returns the image url relative to the post directory" do
expect(subject["path"]).to eql("/2017/01/01/image.png")
end
end
context "with image as a relative path" do
let(:image) { "image.png" }
it "returns the image with the page dir prepended" do
expect(subject["path"]).to eql("/foo/image.png")
end
context "with site.url" do
let(:config) { { "url" => "http://example.com" } }
it "makes the path absolute" do
expect(subject["path"]).to eql("http://example.com/foo/image.png")
end
end
end
context "with image as an absolute path" do
let(:image) { "/image.png" }
it "returns the image" do
expect(subject["path"]).to eql("/image.png")
end
context "with site.url" do
let(:config) { { "url" => "http://example.com" } }
it "makes the path absolute" do
expect(subject["path"]).to eql("http://example.com/image.png")
end
end
context "with a URL-escaped path" do
let(:image) { "/some image.png" }
it "URL-escapes the image" do
expect(subject["path"]).to eql("/some%20image.png")
end
end
end
context "with image as a hash" do
context "with an absolute path" do
let(:image) { { "path" => "/image.png" } }
it "returns the image" do
expect(subject["path"]).to eql("/image.png")
end
end
context "with facebook" do
let(:image) { { "facebook" => "/image.png" } }
it "returns the image" do
expect(subject["path"]).to eql("/image.png")
end
end
context "with twitter" do
let(:image) { { "twitter" => "/image.png" } }
it "returns the image" do
expect(subject["path"]).to eql("/image.png")
end
end
context "with some random hash" do
let(:image) { { "foo" => "bar" } }
it "returns nil" do
expect(subject["path"]).to be_nil
end
it "returns arbitrary values" do
expect(subject["foo"]).to eql("bar")
end
end
context "with an invalid path" do
let(:image) { ":" }
it "returns the path" do
expect(subject["path"]).to eql(":")
end
end
context "with height and width" do
let(:image) { { "path" => "image.png", "height" => 5, "width" => 10 } }
it "returns the height and width" do
expect(subject["height"]).to eql(5)
expect(subject["width"]).to eql(10)
end
end
end
end

View File

@ -0,0 +1,201 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag::JSONLDDrop do
let(:author) { "author" }
let(:image) { "image" }
let(:metadata) do
{
"title" => "title",
"author" => author,
"image" => image,
"date" => "2017-01-01",
"description" => "description",
"seo" => {
"name" => "seo name",
"date_modified" => "2017-01-02",
"links" => %w(a b),
},
}
end
let(:config) do
{
"logo" => "logo",
"timezone" => "America/New_York",
}
end
let(:page) { make_page(metadata) }
let(:site) { make_site(config) }
let(:context) { make_context(:page => page, :site => site) }
let(:page_drop) { Jekyll::SeoTag::Drop.new("", context) }
subject { described_class.new(page_drop) }
before do
Jekyll.logger.log_level = :error
end
it "returns the context" do
expect(subject).to have_key("@context")
expect(subject["@context"]).to eql("https://schema.org")
end
it "returns the type" do
expect(subject).to have_key("@type")
expect(subject["@type"]).to eql("BlogPosting")
end
it "returns the name" do
expect(subject).to have_key("name")
expect(subject["name"]).to eql("seo name")
end
it "returns the headline" do
expect(subject).to have_key("headline")
expect(subject["headline"]).to eql("title")
end
context "author" do
{
"string" => "author",
"hash" => { "name" => "author" },
}.each do |key, value|
context "when passed as a #{key}" do
let(:author) { value }
it "returns the author" do
expect(subject).to have_key("author")
expect(subject["author"]).to be_a(Hash)
expect(subject["author"]).to have_key("@type")
expect(subject["author"]["@type"]).to eql("Person")
expect(subject["author"]).to have_key("name")
expect(subject["author"]["name"]).to be_a(String)
expect(subject["author"]["name"]).to eql("author")
expect(subject["author"]["url"]).to be nil
end
end
end
context "when type Organization" do
let(:author) { { "name" => "organization", "type" => "Organization" } }
it "returns the author with type" do
expect(subject).to have_key("author")
expect(subject["author"]).to be_a(Hash)
expect(subject["author"]).to have_key("@type")
expect(subject["author"]["@type"]).to eql("Organization")
expect(subject["author"]).to have_key("name")
expect(subject["author"]["name"]).to be_a(String)
expect(subject["author"]["name"]).to eql("organization")
end
end
context "when invalid type" do
let(:author) { { "name" => "organization", "type" => "Invalid" } }
it "returns the author with type" do
expect(subject).to have_key("author")
expect(subject["author"]).to be nil
end
end
context "when url is present" do
let(:author) { { "name" => "author", "url" => "https://example.com" } }
it "returns the author with url" do
expect(subject).to have_key("author")
expect(subject["author"]).to be_a(Hash)
expect(subject["author"]).to have_key("url")
expect(subject["author"]["url"]).to eql("https://example.com")
expect(subject["author"]).to have_key("name")
expect(subject["author"]["name"]).to be_a(String)
expect(subject["author"]["name"]).to eql("author")
end
end
end
context "image" do
context "with image as an absolute path" do
let(:image) { "/image" }
it "returns the image as a string" do
expect(subject).to have_key("image")
expect(subject["image"]).to be_a(String)
expect(subject["image"]).to eql("/image")
end
end
context "with image as a hash" do
let(:image) { { "path" => "/image", "height" => 5, "width" => 10 } }
it "returns the image as a hash" do
expect(subject).to have_key("image")
expect(subject["image"]).to be_a(Hash)
expect(subject["image"]).to eql(
"@type" => "imageObject",
"url" => "/image",
"height" => 5,
"width" => 10
)
end
end
end
it "returns the datePublished" do
expect(subject).to have_key("datePublished")
expect(subject["datePublished"]).to eql("2017-01-01T00:00:00-05:00")
end
it "returns the dateModified" do
expect(subject).to have_key("dateModified")
expect(subject["dateModified"]).to eql("2017-01-02T00:00:00-05:00")
end
it "returns the description" do
expect(subject).to have_key("description")
expect(subject["description"]).to eql("description")
end
it "returns the publisher" do
expect(subject).to have_key("publisher")
publisher = subject["publisher"]
expect(publisher).to be_a(Hash)
expect(publisher).to have_key("@type")
expect(publisher["@type"]).to eql("Organization")
expect(publisher).to have_key("logo")
logo = publisher["logo"]
expect(logo).to have_key("@type")
expect(logo["@type"]).to eql("ImageObject")
expect(logo).to have_key("url")
expect(logo["url"]).to eql("/logo")
end
it "returns the main entity of page" do
expect(subject).to have_key("mainEntityOfPage")
expect(subject["mainEntityOfPage"]).to be_a(Hash)
expect(subject["mainEntityOfPage"]).to have_key("@type")
expect(subject["mainEntityOfPage"]["@type"]).to eql("WebPage")
expect(subject["mainEntityOfPage"]).to have_key("@id")
expect(subject["mainEntityOfPage"]["@id"]).to eql("/page.html")
end
it "returns sameAs" do
expect(subject).to have_key("sameAs")
expect(subject["sameAs"]).to be_a(Array)
expect(subject["sameAs"]).to eql(%w(a b))
end
it "returns the url" do
expect(subject).to have_key("url")
expect(subject["url"]).to eql("/page.html")
end
context "with null values" do
let(:metadata) { {} }
it "does not return null values as json" do
expect(subject.to_json).to_not match(%r!:null!)
end
end
end

View File

@ -0,0 +1,720 @@
# frozen_string_literal: true
RSpec.describe Jekyll::SeoTag do
let(:page) { make_page }
let(:site) { make_site }
let(:post) { make_post }
let(:context) { make_context(:page => page, :site => site) }
let(:tag) { "seo" }
let(:text) { "" }
let(:output) { Liquid::Template.parse("{% #{tag} #{text} %}").render!(context, {}) }
let(:json) { output.match(%r!<script type="application/ld\+json">(.*)</script>!m)[1] }
let(:json_data) { JSON.parse(json) }
let(:paginator) { { "previous_page" => true, "previous_page_path" => "foo", "next_page" => true, "next_page_path" => "bar" } }
before do
Jekyll.logger.log_level = :error
end
it "builds" do
expect(output).to match(%r!Jekyll SEO tag!i)
end
it "outputs the plugin version" do
version = Jekyll::SeoTag::VERSION
expect(output).to match(%r!Jekyll SEO tag v#{version}!i)
end
it "outputs meta generator" do
version = Jekyll::VERSION
expect(output).to match(%r!Jekyll v#{version}!i)
end
it "outputs JSON sorted by key" do
expect(json.strip).to eql('{"@context":"https://schema.org","@type":"WebPage","url":"/page.html"}')
end
it "outputs valid HTML" do
site.process
options = {
:check_html => true,
:checks_to_ignore => %w(ScriptCheck LinkCheck ImageCheck),
}
status = HTMLProofer.check_directory(dest_dir, options).run
expect(status).to eql(true)
end
context "with page.title" do
let(:page) { make_page("title" => "foo") }
it "builds the title with a page title only" do
expect(output).to match(%r!<title>foo</title>!)
expected = %r!<meta property="og:title" content="foo" />!
expect(output).to match(expected)
end
context "with site.name" do
let(:site) { make_site("name" => "Site Name") }
it "builds the title with a page title and site name" do
expect(output).to match(%r!<title>foo \| Site Name</title>!)
end
end
context "with site.title" do
let(:site) { make_site("title" => "bar") }
it "builds the title with a page title and site title" do
expect(output).to match(%r!<title>foo \| bar</title>!)
end
end
context "with site.description" do
let(:site) { make_site("description" => "Site Description") }
it "builds the title without the site description" do
expect(output).not_to match(%r!<title>foo \| Site Description</title>!)
end
end
context "with site.title and site.description" do
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
it "builds the title with a page title and site title" do
expect(output).to match(%r!<title>foo \| Site Title</title>!)
end
it "does not build the title with the site description" do
expect(output).not_to match(%r!<title>foo \| Site Description</title>!)
end
end
context "with site.title and site.description" do
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
it "builds the title with a page title and site title" do
expect(output).to match(%r!<title>foo \| Site Title</title>!)
end
it "does not build the title with the site description" do
expect(output).not_to match(%r!<title>Page Title \| Site Description</title>!)
end
end
end
context "with site.title" do
let(:site) { make_site("title" => "Site title") }
it "builds the title with only a site title" do
expect(output).to match(%r!<title>Site title</title>!)
end
end
context "with site.title and site.description" do
let(:site) { make_site("title" => "Site Title", "description" => "Site Description") }
it "builds the title with site title and description" do
expect(output).to match(%r!<title>Site Title \| Site Description</title>!)
end
end
context "with page.description" do
let(:page) { make_page("description" => "foo") }
it "uses the page description" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
end
end
context "with page.excerpt" do
let(:page) { make_page("excerpt" => "foo") }
it "uses the page excerpt when no page description exists" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
end
end
context "with site.description" do
let(:site) { make_site("description" => "foo") }
it "uses the site description when no page description nor excerpt exist" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
expect(output).to match(%r!<meta property="twitter:description" content="foo" />!)
end
end
context "with site.url" do
let(:site) { make_site("url" => "http://example.invalid") }
it "uses the site url to build the seo url" do
expected = %r!<link rel="canonical" href="http://example.invalid/page.html" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/page.html" />!
expect(output).to match(expected)
end
context "with page.permalink" do
let(:page) { make_page("permalink" => "/page/index.html") }
it "uses replaces '/index.html' with '/'" do
expected = %r!<link rel="canonical" href="http://example.invalid/page/" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/page/" />!
expect(output).to match(expected)
end
end
context "with site.baseurl" do
let(:site) { make_site("url" => "http://example.invalid", "baseurl" => "/foo") }
it "uses baseurl to build the seo url" do
expected = %r!<link rel="canonical" href="http://example.invalid/foo/page.html" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/foo/page.html" />!
expect(output).to match(expected)
end
end
context "with relative page.image as a string" do
let(:page) { make_page("image" => "/img/foo.png") }
it "outputs an open graph image" do
expected = '<meta property="og:image" content="http://example.invalid/img/foo.png" />'
expect(output).to include(expected)
end
end
context "with absolute page.image" do
let(:page) { make_page("image" => "http://cdn.example.invalid/img/foo.png") }
it "outputs an open graph image" do
expected = '<meta property="og:image" content="http://cdn.example.invalid/img/foo.png" />'
expect(output).to include(expected)
end
end
context "with page.image as an object" do
context "when given a path" do
let(:page) { make_page("image" => { "path" => "/img/foo.png" }) }
it "outputs an open graph image" do
expected = %r!<meta property="og:image" content="http://example.invalid/img/foo.png" />!
expect(output).to match(expected)
end
end
context "when given a facebook image" do
let(:page) { make_page("image" => { "facebook" => "/img/facebook.png" }) }
it "outputs an open graph image" do
expected = %r!<meta property="og:image" content="http://example.invalid/img/facebook.png" />!
expect(output).to match(expected)
end
end
context "when given a twitter image" do
let(:page) { make_page("image" => { "twitter" => "/img/twitter.png" }) }
it "outputs an open graph image" do
expected = %r!<meta property="og:image" content="http://example.invalid/img/twitter.png" />!
expect(output).to match(expected)
end
end
context "when given an image height and width" do
let(:image) { { "path" => "/img/foo.png", "height" => 1, "width" => 2 } }
let(:page) { make_page("image" => image) }
it "outputs an open graph image width and height" do
expected = %r!<meta property="og:image:height" content="1" />!
expect(output).to match(expected)
expected = %r!<meta property="og:image:width" content="2" />!
expect(output).to match(expected)
end
end
end
context "with site.logo" do
let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") }
it "outputs the logo" do
expect(json_data["publisher"]["logo"]["url"]).to eql("http://example.invalid/logo.png")
end
end
context "with absolute site.logo" do
let(:site) { make_site("logo" => "http://cdn.example.invalid/logo.png", "url" => "http://example.invalid") }
it "outputs the logo" do
expect(json_data["publisher"]["logo"]["url"]).to eql("http://cdn.example.invalid/logo.png")
end
end
context "with site.logo and page.author" do
let(:site) { make_site("logo" => "http://cdn.example.invalid/logo.png", "url" => "http://example.invalid", "author" => "Mr. Foo") }
it "outputs the author" do
expect(json_data["publisher"]["name"]).to eql("Mr. Foo")
end
end
context "with page author" do
let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") }
let(:page) { make_post("author" => "Mr. Foo") }
it "outputs the author" do
expect(json_data["author"]["@type"]).to eql("Person")
expect(json_data["author"]["name"]).to eql("Mr. Foo")
end
it "outputs the publisher author" do
expect(json_data["publisher"]["name"]).to eql("Mr. Foo")
end
end
context "with seo type is BlogPosting" do
let(:site) { make_site("url" => "http://example.invalid") }
let(:page) { make_post("seo" => { "type" => "BlogPosting" }, "permalink" => "/foo/") }
it "outputs the mainEntityOfPage" do
expect(json_data["mainEntityOfPage"]["@type"]).to eql("WebPage")
expect(json_data["mainEntityOfPage"]["@id"]).to eql("http://example.invalid/foo/")
end
end
context "with seo type is CreativeWork" do
let(:site) { make_site("url" => "http://example.invalid") }
let(:page) { make_post("seo" => { "type" => "CreativeWork" }, "permalink" => "/foo/") }
it "outputs the mainEntityOfPage" do
expect(json_data["mainEntityOfPage"]["@type"]).to eql("WebPage")
expect(json_data["mainEntityOfPage"]["@id"]).to eql("http://example.invalid/foo/")
end
end
context "with site.title" do
let(:site) { make_site("title" => "Foo", "url" => "http://example.invalid") }
it "outputs the site title meta" do
expect(output).to match(%r!<meta property="og:site_name" content="Foo" />!)
end
it "minifies the output" do
version = Jekyll::SeoTag::VERSION
expected = <<~HTML
<!-- Begin Jekyll SEO tag v#{version} -->
<title>Foo</title>
<meta name="generator" content="Jekyll v#{Jekyll::VERSION}" />
<meta property="og:title" content="Foo" />
<meta property="og:locale" content="en_US" />
<link rel="canonical" href="http://example.invalid/page.html" />
<meta property="og:url" content="http://example.invalid/page.html" />
<meta property="og:site_name" content="Foo" />
HTML
expect(output).to match(expected)
end
end
end
context "posts" do
context "with post meta" do
let(:site) { make_site("url" => "http://example.invalid") }
let(:meta) do
{
"title" => "post",
"description" => "description",
"image" => "/img.png",
}
end
let(:page) { make_post(meta) }
it "outputs post meta" do
expected = %r!<meta property="og:type" content="article" />!
expect(output).to match(expected)
expect(json_data["headline"]).to eql("post")
expect(json_data["description"]).to eql("description")
expect(json_data["image"]).to eql("http://example.invalid/img.png")
end
it "minifies JSON-LD" do
expect(output).to_not match(%r!{.*?\s.*?}!)
end
it "removes null values from JSON-LD" do
expect(output).to_not match(%r!:null!)
end
context "description" do
context "with page.seo_description_max_words" do
let(:meta) do
{
"title" => "post",
"description" => "For a long time, I went to bed early",
"image" => "/img.png",
"seo_description_max_words" => 6,
}
end
it "truncates the description" do
expect(json_data["description"]).to eql("For a long time, I went…")
end
end
end
end
end
context "facebook" do
let(:site_facebook) do
{
"admins" => "jekyllrb-fb-admins",
"app_id" => "jekyllrb-fb-app_id",
"publisher" => "jekyllrb-fb-publisher",
}
end
let(:site) { make_site("facebook" => site_facebook) }
it "outputs facebook admins meta" do
expected = %r!<meta property="fb:admins" content="jekyllrb-fb-admins" />!
expect(output).to match(expected)
end
it "outputs facebook app ID meta" do
expected = %r!<meta property="fb:app_id" content="jekyllrb-fb-app_id" />!
expect(output).to match(expected)
end
it "outputs facebook article publisher meta" do
expected = %r!<meta property="article:publisher" content="jekyllrb-fb-publisher" />!
expect(output).to match(expected)
end
end
context "twitter" do
context "with site.twitter.username" do
let(:site_twitter) { { "username" => "jekyllrb" } }
let(:site) { make_site("twitter" => site_twitter) }
context "with page.author as a string" do
let(:page) { make_page("author" => "benbalter") }
it "outputs twitter card meta" do
expected = %r!<meta name="twitter:card" content="summary" />!
expect(output).to match(expected)
expected = %r!<meta name="twitter:site" content="@jekyllrb" />!
expect(output).to match(expected)
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
context "with an @" do
let(:page) { make_page("author" => "@benbalter") }
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
end
context "with site.data.authors" do
let(:author_data) { {} }
let(:data) { { "authors" => author_data } }
let(:site) { make_site("data" => data, "twitter" => site_twitter) }
context "with the author in site.data.authors" do
let(:author_data) { { "benbalter" => { "twitter" => "test" } } }
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "without the author in site.data.authors" do
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
end
end
end
context "with page.image" do
context "without *.twitter.card" do
let(:page) { make_page("image" => "/img/foo.png") }
it "outputs summary card with large image" do
expected = %r!<meta name="twitter:card" content="summary_large_image" />!
expect(output).to match(expected)
end
end
context "with page.twitter.card" do
let(:page_twitter) { { "card" => "summary" } }
let(:page) { make_page("image" => "/img/foo.png", "twitter" => page_twitter) }
it "outputs summary card with small image" do
expected = %r!<meta name="twitter:card" content="summary" />!
expect(output).to match(expected)
end
end
context "with site.twitter.card" do
let(:site_twitter) { { "username" => "jekyllrb", "card" => "summary" } }
let(:site) { make_site("twitter" => site_twitter) }
let(:page) { make_page("image" => "/img/foo.png") }
it "outputs summary card with small image" do
expected = %r!<meta name="twitter:card" content="summary" />!
expect(output).to match(expected)
end
end
end
context "with page.author as a hash" do
let(:page) { make_page("author" => { "twitter" => "@test" }) }
it "supports author data as a hash" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "with page.authors as an array" do
let(:page) { make_page("authors" => %w(test foo)) }
it "supports author data as an array" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "with site.author as a hash" do
let(:author) { { "twitter" => "@test" } }
let(:site) { make_site("author" => author, "twitter" => site_twitter) }
it "supports author data as an hash" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
end
end
context "author" do
let(:site) { make_site("author" => "Site Author") }
context "with site.author" do
it "outputs site author metadata" do
expected = %r!<meta name="author" content="Site Author" />!
expect(output).to match(expected)
end
end
context "with page.author" do
let(:page) { make_page("author" => "Page Author") }
it "outputs page author metadata" do
expected = %r!<meta name="author" content="Page Author" />!
expect(output).to match(expected)
end
end
context "without page.author" do
let(:page) { make_page("author" => "") }
it "outputs site author metadata" do
expected = %r!<meta name="author" content="Site Author" />!
expect(output).to match(expected)
end
end
context "with site.data.authors" do
let(:author_data) { { "renshuki" => { "name" => "Site Data Author" } } }
let(:data) { { "authors" => author_data } }
context "with the author in site.data.authors" do
let(:site) { make_site("data" => data, "author" => "renshuki") }
it "outputs the author metadata" do
expected = %r!<meta name="author" content="Site Data Author" />!
expect(output).to match(expected)
end
end
context "without the author in site.data.authors" do
it "outputs site author metadata" do
expected = %r!<meta name="author" content="Site Author" />!
expect(output).to match(expected)
end
end
end
end
context "with site.social" do
let(:links) { ["http://foo.invalid", "http://bar.invalid"] }
let(:social_namespace) { { "name" => "Ben", "links" => links } }
let(:site) { make_site("social" => social_namespace) }
let(:page) { make_post(meta) }
context "on homepage" do
let(:meta) do
{
"permalink" => "/",
"seo" => {
"type" => "person",
},
}
end
it "outputs social meta" do
expect(json_data["@type"]).to eql("person")
expect(json_data["name"]).to eql("Ben")
expect(json_data["sameAs"]).to eql(links)
end
end
context "on about page" do
let(:meta) { { "permalink" => "/about/" } }
it "outputs sameAs links" do
expect(json_data["sameAs"]).to eql(links)
end
end
context "on other pages" do
let(:meta) { { "permalink" => "/2/" } }
it "does not output sameAs links" do
expect(json_data["sameAs"]).to be_nil
end
end
end
context "with site.name" do
let(:site) { make_site("name" => "Site name") }
it "uses site.name if site.title is not present" do
expected = %r!<meta property="og:site_name" content="Site name" />!
expect(output).to match(expected)
end
context "with site.title" do
let(:site) { make_site("name" => "Site Name", "title" => "Site Title") }
it "uses site.tile if both site.title and site.name are present" do
expected = %r!<meta property="og:site_name" content="Site Title" />!
expect(output).to match(expected)
end
end
end
context "with title=false" do
let(:text) { "title=false" }
it "does not output a <title> tag" do
expect(output).not_to match(%r!<title>!)
end
end
context "with pagination" do
let(:context) { make_context({}, "paginator" => paginator) }
it "outputs pagination links" do
expect(output).to match(%r!<link rel="prev" href="/foo" />!)
expect(output).to match(%r!<link rel="next" href="/bar" />!)
end
end
context "webmaster verification" do
context "with site.webmaster_verifications" do
let(:site_verifications) do
{
"google" => "foo",
"bing" => "bar",
"alexa" => "baz",
"yandex" => "bat",
"facebook" => "bas",
}
end
let(:site) { make_site("webmaster_verifications" => site_verifications) }
it "outputs google verification meta" do
expected = %r!<meta name="google-site-verification" content="foo" />!
expect(output).to match(expected)
end
it "outputs bing verification meta" do
expected = %r!<meta name="msvalidate.01" content="bar" />!
expect(output).to match(expected)
end
it "outputs alexa verification meta" do
expected = %r!<meta name="alexaVerifyID" content="baz" />!
expect(output).to match(expected)
end
it "outputs yandex verification meta" do
expected = %r!<meta name="yandex-verification" content="bat" />!
expect(output).to match(expected)
end
it "outputs facebook verification meta" do
expected = %r!<meta name="facebook-domain-verification" content="bas" />!
expect(output).to match(expected)
end
end
context "with site.google_site_verification" do
let(:site) { make_site("google_site_verification" => "foo") }
it "outputs google verification meta" do
expected = %r!<meta name="google-site-verification" content="foo" />!
expect(output).to match(expected)
end
end
end
context "with locale" do
it "uses en_US when no locale is specified" do
expected = %r!<meta property="og:locale" content="en_US" />!
expect(output).to match(expected)
end
context "with site.lang" do
let(:site) { make_site("lang" => "de_DE") }
it "uses site.lang if page.lang is not present" do
expected = %r!<meta property="og:locale" content="de_DE" />!
expect(output).to match(expected)
end
context "with page.lang" do
let(:page) { make_page("lang" => "en_UK") }
it "uses page.lang if both site.lang and page.lang are present" do
expected = %r!<meta property="og:locale" content="en_UK" />!
expect(output).to match(expected)
end
end
end
context "with site.lang hyphenated" do
let(:site) { make_site("lang" => "en-AU") }
it "coerces hyphen to underscore" do
expected = %r!<meta property="og:locale" content="en_AU" />!
expect(output).to match(expected)
end
end
end
end

View File

@ -1,443 +1,52 @@
require "spec_helper"
# frozen_string_literal: true
describe Jekyll::SeoTag do
let(:page) { make_page }
let(:site) { make_site }
let(:post) { make_post }
let(:context) { make_context(:page => page, :site => site) }
let(:tag) { "seo" }
let(:text) { "" }
let(:output) { Liquid::Template.parse("{% #{tag} #{text} %}").render!(context, {}) }
let(:json) { output.match(%r!<script type=\"application/ld\+json\">(.*)</script>!m)[1] }
let(:json_data) { JSON.parse(json) }
let(:paginator) { { "previous_page" => true, "previous_page_path" => "foo", "next_page" => true, "next_page_path" => "bar" } }
RSpec.describe Jekyll::SeoTag do
let(:config) { { "title" => "site title" } }
let(:page_meta) { {} }
let(:page) { make_page(page_meta) }
let(:site) { make_site(config) }
let(:render_context) { make_context(:page => page, :site => site) }
let(:text) { "" }
let(:tag_name) { "github_edit_link" }
let(:tokenizer) { Liquid::Tokenizer.new("") }
let(:parse_context) { Liquid::ParseContext.new }
let(:rendered) { subject.render(render_context) }
let(:payload) { subject.send(:payload) }
subject do
tag = described_class.parse(tag_name, text, tokenizer, parse_context)
tag.instance_variable_set("@context", render_context)
tag
end
before do
Jekyll.logger.log_level = :error
end
it "builds" do
expect(output).to match(%r!Jekyll SEO tag!i)
it "returns the template" do
expect(described_class.template).to be_a(Liquid::Template)
end
it "outputs the plugin version" do
version = Jekyll::SeoTag::VERSION
expect(output).to match(%r!Jekyll SEO tag v#{version}!i)
end
it "outputs valid HTML" do
site.process
options = {
:check_html => true,
:checks_to_ignore => %w(ScriptCheck LinkCheck ImageCheck)
}
status = HTML::Proofer.new(dest_dir, options).run
expect(status).to eql(true)
end
context "with page.title" do
let(:page) { make_page("title" => "foo") }
it "builds the title with a page title only" do
expect(output).to match(%r!<title>foo</title>!)
expected = %r!<meta property="og:title" content="foo" />!
expect(output).to match(expected)
context "payload" do
it "contains the drop" do
expect(payload["seo_tag"]).to be_a(Jekyll::SeoTag::Drop)
end
context "with site.title" do
let(:site) { make_site("title" => "bar") }
it "contains the Jekyll drop" do
expect(payload["jekyll"]).to be_a(Jekyll::Drops::JekyllDrop)
end
it "builds the title with a page title and site title" do
expect(output).to match(%r!<title>foo - bar</title>!)
end
it "contains the page" do
expect(payload["page"]).to be_a(Jekyll::Page)
end
it "contains the site" do
expect(payload["site"]).to be_a(Jekyll::Drops::SiteDrop)
end
end
context "with site.title" do
let(:site) { make_site("title" => "Site title") }
it "builds the title with only a site title" do
expect(output).to match(%r!<title>Site title</title>!)
end
end
context "with page.description" do
let(:page) { make_page("description" => "foo") }
it "uses the page description" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
end
end
context "with page.excerpt" do
let(:page) { make_page("excerpt" => "foo") }
it "uses the page excerpt when no page description exists" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
end
end
context "with site.description" do
let(:site) { make_site("description" => "foo") }
it "uses the site description when no page description nor excerpt exist" do
expect(output).to match(%r!<meta name="description" content="foo" />!)
expect(output).to match(%r!<meta property="og:description" content="foo" />!)
end
end
context "with site.url" do
let(:site) { make_site("url" => "http://example.invalid") }
it "uses the site url to build the seo url" do
expected = %r!<link rel="canonical" href="http://example.invalid/page.html" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/page.html" />!
expect(output).to match(expected)
end
context "with page.permalink" do
let(:page) { make_page("permalink" => "/page/index.html") }
it "uses replaces '/index.html' with '/'" do
expected = %r!<link rel="canonical" href="http://example.invalid/page/" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/page/" />!
expect(output).to match(expected)
end
end
context "with site.baseurl" do
let(:site) { make_site("url" => "http://example.invalid", "baseurl" => "/foo") }
it "uses baseurl to build the seo url" do
expected = %r!<link rel="canonical" href="http://example.invalid/foo/page.html" />!
expect(output).to match(expected)
expected = %r!<meta property="og:url" content="http://example.invalid/foo/page.html" />!
expect(output).to match(expected)
end
end
context "with relative page.image as a string" do
let(:page) { make_page("image" => "/img/foo.png") }
it "outputs the image" do
expected = '<meta property="og:image" content="http://example.invalid/img/foo.png" />'
expect(output).to include(expected)
end
end
context "with absolute page.image" do
let(:page) { make_page("image" => "http://cdn.example.invalid/img/foo.png") }
it "outputs the image" do
expected = '<meta property="og:image" content="http://cdn.example.invalid/img/foo.png" />'
expect(output).to include(expected)
end
end
context "with page.image as an object" do
context "when given a path" do
let(:page) { make_page("image" => { "path" => "/img/foo.png" }) }
it "outputs the image" do
expected = %r!<meta property="og:image" content="http://example.invalid/img/foo.png" />!
expect(output).to match(expected)
end
end
context "when given a facebook image" do
let(:page) { make_page("image" => { "facebook" => "/img/facebook.png" }) }
it "outputs the image" do
expected = %r!<meta property="og:image" content="http://example.invalid/img/facebook.png" />!
expect(output).to match(expected)
end
end
context "when given a twitter image" do
let(:page) { make_page("image" => { "twitter" => "/img/twitter.png" }) }
it "outputs the image" do
expected = %r!<meta name="twitter:image" content="http://example.invalid/img/twitter.png" />!
expect(output).to match(expected)
end
end
context "when given the image height and width" do
let(:image) { { "facebook" => "/img/foo.png", "height" => 1, "width" => 2 } }
let(:page) { make_page("image" => image) }
it "outputs the image" do
expected = %r!<meta property="og:image:height" content="1" />!
expect(output).to match(expected)
expected = %r!<meta property="og:image:width" content="2" />!
expect(output).to match(expected)
end
end
end
context "with site.logo" do
let(:site) { make_site("logo" => "/logo.png", "url" => "http://example.invalid") }
it "outputs the logo" do
expect(json_data["logo"]).to eql("http://example.invalid/logo.png")
end
end
context "with absolute site.logo" do
let(:site) { make_site("logo" => "http://cdn.example.invalid/logo.png", "url" => "http://example.invalid") }
it "outputs the logo" do
expect(json_data["logo"]).to eql("http://cdn.example.invalid/logo.png")
end
end
context "with site.title" do
let(:site) { make_site("title" => "Foo", "url" => "http://example.invalid") }
it "outputs the site title meta" do
expect(output).to match(%r!<meta property="og:site_name" content="Foo" />!)
end
it "minifies the output" do
version = Jekyll::SeoTag::VERSION
expected = <<-EOS
<!-- Begin Jekyll SEO tag v#{version} -->
<title>Foo</title>
<meta property="og:title" content="Foo" />
<link rel="canonical" href="http://example.invalid/page.html" />
<meta property="og:url" content="http://example.invalid/page.html" />
<meta property="og:site_name" content="Foo" />
EOS
expect(output).to match(expected)
end
end
end
context "posts" do
context "with post meta" do
let(:site) { make_site("url" => "http://example.invalid") }
let(:meta) do
{
"title" => "post",
"description" => "description",
"image" => "/img.png"
}
end
let(:page) { make_post(meta) }
it "outputs post meta" do
expected = %r!<meta property="og:type" content="article" />!
expect(output).to match(expected)
expect(json_data["headline"]).to eql("post")
expect(json_data["description"]).to eql("description")
expect(json_data["image"]).to eql("http://example.invalid/img.png")
end
it "minifies JSON-LD" do
expected = <<-EOS
{"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "post",
EOS
expect(output).to match(expected)
end
end
end
context "facebook" do
let(:site_facebook) do
{
"admins" => "jekyllrb-fb-admins",
"app_id" => "jekyllrb-fb-app_id",
"publisher" => "jekyllrb-fb-publisher"
}
end
let(:site) { make_site("facebook" => site_facebook) }
it "outputs facebook admins meta" do
expected = %r!<meta property="fb:admins" content="jekyllrb-fb-admins" />!
expect(output).to match(expected)
end
it "outputs facebook app ID meta" do
expected = %r!<meta property="fb:app_id" content="jekyllrb-fb-app_id" />!
expect(output).to match(expected)
end
it "outputs facebook article publisher meta" do
expected = %r!<meta property="article:publisher" content="jekyllrb-fb-publisher" />!
expect(output).to match(expected)
end
end
context "twitter" do
context "with site.twitter.username" do
let(:site_twitter) { { "username" => "jekyllrb" } }
let(:site) { make_site("twitter" => site_twitter) }
context "with page.author as a string" do
let(:page) { make_page("author" => "benbalter") }
it "outputs twitter card meta" do
expected = %r!<meta name="twitter:card" content="summary" />!
expect(output).to match(expected)
expected = %r!<meta name="twitter:site" content="@jekyllrb" />!
expect(output).to match(expected)
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
context "with an @" do
let(:page) { make_page("author" => "@benbalter") }
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
end
context "with site.data.authors" do
let(:author_data) { {} }
let(:data) { { "authors" => author_data } }
let(:site) { make_site("data" => data, "twitter" => site_twitter) }
context "with the author in site.data.authors" do
let(:author_data) { { "benbalter" => { "twitter" => "test" } } }
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "without the author in site.data.authors" do
it "outputs the twitter card" do
expected = %r!<meta name="twitter:creator" content="@benbalter" />!
expect(output).to match(expected)
end
end
end
end
context "with page.image" do
let(:page) { make_page("image" => "/img/foo.png") }
it "outputs summary card with large image" do
expected = %r!<meta name="twitter:card" content="summary_large_image" />!
expect(output).to match(expected)
end
end
context "with page.author as a hash" do
let(:page) { make_page("author" => { "twitter" => "@test" }) }
it "supports author data as a hash" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "with page.authors as an array" do
let(:page) { make_page("authors" => %w(test foo)) }
it "supports author data as an array" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
context "with site.author as a hash" do
let(:author) { { "twitter" => "@test" } }
let(:site) { make_site("author" => author, "twitter" => site_twitter) }
it "supports author data as an hash" do
expected = %r!<meta name="twitter:creator" content="@test" />!
expect(output).to match(expected)
end
end
end
end
context "with site.social" do
let(:links) { ["http://foo.invalid", "http://bar.invalid"] }
let(:social_namespace) { { "name" => "Ben", "links" => links } }
let(:site) { make_site("social" => social_namespace) }
let(:page) { make_post(meta) }
context "on homepage" do
let(:meta) do
{
"permalink" => "/",
"seo" => {
"type" => "person"
}
}
end
it "outputs social meta" do
expect(json_data["@type"]).to eql("person")
expect(json_data["name"]).to eql("Ben")
expect(json_data["sameAs"]).to eql(links)
end
end
context "on about page" do
let(:meta) { { "permalink" => "/about/" } }
it "outputs sameAs links" do
expect(json_data["sameAs"]).to eql(links)
end
end
context "on other pages" do
let(:meta) { { "permalink" => "/2/" } }
it "does not output sameAs links" do
expect(json_data["sameAs"]).to be_nil
end
end
end
context "with site.name" do
let(:site) { make_site("name" => "Site name") }
it "uses site.name if site.title is not present" do
expected = %r!<meta property="og:site_name" content="Site name" />!
expect(output).to match(expected)
end
context "with site.title" do
let(:site) { make_site("name" => "Site Name", "title" => "Site Title") }
it "uses site.tile if both site.title and site.name are present" do
expected = %r!<meta property="og:site_name" content="Site Title" />!
expect(output).to match(expected)
end
end
end
context "with title=false" do
let(:text) { "title=false" }
it "does not output a <title> tag" do
expect(output).not_to match(%r!<title>!)
end
end
context "with pagination" do
let(:context) { make_context({}, "paginator" => paginator) }
it "outputs pagination links" do
expect(output).to match(%r!<link rel="prev" href="/foo">!)
expect(output).to match(%r!<link rel="next" href="/bar">!)
end
it "renders" do
expected = "<!-- Begin Jekyll SEO tag v#{described_class::VERSION} -->"
expect(rendered).to match(expected)
end
end

View File

@ -1,26 +1,37 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "jekyll"
require "jekyll-seo-tag"
require "html/proofer"
require "html-proofer"
# Monkey patch Jekyll::Drops::Drop so Rspec's `have_key` works as expected
module Jekyll
module Drops
class Drop
alias_method :has_key?, :key?
end
end
end
ENV["JEKYLL_LOG_LEVEL"] = "error"
def dest_dir
File.expand_path("../tmp/dest", File.dirname(__FILE__))
File.expand_path("../tmp/dest", __dir__)
end
def source_dir
File.expand_path("./fixtures", File.dirname(__FILE__))
File.expand_path("fixtures", __dir__)
end
CONFIG_DEFAULTS = {
"source" => source_dir,
"destination" => dest_dir,
"gems" => ["jekyll-seo-tag"]
"gems" => ["jekyll-seo-tag"],
}.freeze
def make_page(options = {})
page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], "", "page.md"
page = Jekyll::Page.new site, CONFIG_DEFAULTS["source"], options.delete("dir") || "", "page.md"
page.data = options
page
end