:point_right: Live demo: https://erikw.github.io/jekyll-google_search_console_verification_file/
This is a very simple plugin that will generate a Google Search Console (GSC from here on) verification file to your _site/
directory in a Jekyll project. This file is used by GSC to verify that you own the site and looks for example like my googlef47733b3288357e4.html.
Why use this plugin?
<meta>
tag to all your HTML pages; use simple file in the site's rootThere are multiple ways to verify the ownership of your site. The two simpler ways, both suitable for Github Pages owners, are to add an <meta> tag to your pages
or upload a special unique file to the root of the site. For adding the meta tag, there are excellent plugins making this very easy for example jekyll-seo-tag. If you want to the meta tag, I recommend this plugin.
However if you feel that it's bloated to add this <meta>
tag to the header all you pages, keeping file size and page load speed in mind, you may one to go for the file based verification method instead.
So with the file based method, why not just add the file you downloaded from GSC to your source directory and let Jekyll put it in _site/
on generation? As we're using a SSG (Static Site Generator), we should generate everything we can. It's verdantly nice to keep the source tree clean and make everything that can be a configuration that generates what is needed.
Thus, this plugin exist to solve this problem. Give the plugin the unique code GSC provided you and it will generate the file for you in _site/
!
Note that if you do place a verification file in the root of the source tree, this will override the generation by this plugin.
:jekyll_plugins
group:bundle add --group jekyll_plugins jekyll-google_search_console_verification_file
group :jekyll_plugins do
[...]
gem 'jekyll-google_search_console_verification_file'
end
$ bundle install
._config.yml
, enable the plugin:plugins:
- jekyll-google_search_console_verification_file
googlef47733b3288357e4.html
copy f47733b3288357e4
._config.yml
, configure this plugin with the code from the previous step:google_search_console:
verification_file_code: 47733b3288357e4
$ bundle exec jekyll build
$ ls _site/ | grep "google.*\.html"
google47733b3288357e4.html
The structure of this plugin was inspired by https://ayastreb.me/writing-a-jekyll-plugin/, the plugin jekyll-sitemap and the Bundler Gem tutorial.
After checking out the repo;
script/setup
to install dependenciesscript/test
to run the testsscript/console
for an interactive prompt that will allow you to experiment.To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Following the setup at how-to-specify-local-ruby-gems-in-your-gemfile, these are the steps needed to build a jekyll site with a local clone of this plugin for local testing.
~/src/jekyll-google_search_console_verification_file
Gemfile
:gem 'jekyll-google_search_console_verification_file'
partgem 'jekyll-google_search_console_verification_file', github: 'erikw/jekyll-google_search_console_verification_file', branch: 'main'
$ bundle config --local local.jekyll-google_search_console_verification_file ~/src/jekyll-google_search_console_verification_file
$ bundle install
bundle exec jekyll build
$ bundle config --delete local.jekyll-google_search_console_verification_file
Gemfile
or keep building from a branch in the github repo.Instructions for releasing on rubygems.org below. Optionally make a GitHub release after this for the pushed git tag.
Following instructions from bundler.io:
vi -p lib/jekyll-google_search_console_verification_file/version.rb CHANGELOG.md
bundle exec rake build
ver=$(ruby -r jekyll-google_search_console_verification_file/version -e 'puts Jekyll::GoogleSearchConsoleVerificationFile::VERSION')
# Optional: test locally by including in another project
gem install pkg/jekyll-google_search_console_verification_file-$ver.gem
bundle exec rake release
Using gem-release:
vi CHANGELOG.md && git add CHANGELOG.md && git commit -m "Update CHANGELOG.md" && git push
gem bump --version minor --tag --push --release --sign
For --version
, use major|minor|patch
as needed.
.gemspec
.Appraisals
to generate different gemfiles/
BUNDLE_GEMFILE=gemfiles/jekyll_4.x.x.gemfile bundle exec rake spec
bundle exec appraisal jekyll-4.x.x rake spec
rake spec
for all gemfiles:bundle exec appraisal rake spec
Appraisals
bundle exec appraisal install
bundle exec appraisal generate --travis
To use the travis cli client (installed from Gemfile
):
travis-cli
repo
, read:org
, user:email
according to the docs.--pro
to most commandsbundle exec travis endpoint --set-default --api-endpoint https://api.travis-ci.com/
bundle exec travis login --github-token $GITHUB_TOKEN
--pro
to use travis.com)bundle exec travis lint
bundle exec travis accounts
bundle exec travis status
bundle exec travis branches
bundle exec travis monitor
Bug reports and pull requests are welcome on GitHub at https://github.com/erikw/jekyll-google_search_console_verification_file.
The gem is available as open source under the terms of the MIT License.
Check out my other Jekyll repositories here.