aarongustafson/jekyll-crosspost-to-medium

Invalid canonical text

Closed this issue · 6 comments

Here is my config.

After publishing url is about:invalid#zSoyz on Medium.

I tried to debug with:

if @settings['text']
          canonical_text = "#{@settings['text']}"
          canonical_text = canonical_text.gsub /{{ url }}/, canonical_url
+          puts "START"
+          puts @site.config
+          puts @site.config['url']
+          puts @settings['text']
+          puts canonical_url
+          puts canonical_text
+          puts "END"
      # Otherwise, use boilerplate
      else

Got:

START
{"source"=>"/srv/jekyll", "destination"=>"/srv/jekyll/_site", "collections_dir"=>"", "plugins_dir"=>"_plugins", "layouts_dir"=>"_layouts", "data_dir"=>"_data", "includes_dir"=>"_includes", "collections"=>{"posts"=>{"output"=>true, "permalink"=>"/:categories/:year/:month/:day/:title:output_ext"}}, "safe"=>false, "include"=>[".htaccess"], "exclude"=>["README.md", "docker-compose.yml", "vendor"], "keep_files"=>[".git", ".svn"], "encoding"=>"utf-8", "markdown_ext"=>"markdown,mkdown,mkdn,mkd,md", "strict_front_matter"=>false, "show_drafts"=>nil, "limit_posts"=>0, "future"=>false, "unpublished"=>false, "whitelist"=>[], "plugins"=>["jekyll-seo-tag", "jekyll-paginate", "jekyll-crosspost-to-medium"], "markdown"=>"kramdown", "highlighter"=>"rouge", "lsi"=>false, "excerpt_separator"=>"<!--more-->", "incremental"=>false, "detach"=>false, "port"=>"4000", "host"=>"0.0.0.0", "baseurl"=>nil, "show_dir_listing"=>false, "permalink"=>"date", "paginate_path"=>"/page:num", "timezone"=>nil, "quiet"=>false, "verbose"=>false, "defaults"=>[], "liquid"=>{"error_mode"=>"warn"}, "rdiscount"=>{"extensions"=>[]}, "redcarpet"=>{"extensions"=>[]}, "kramdown"=>{"auto_ids"=>true, "toc_levels"=>"1..6", "entity_output"=>"as_char", "smart_quotes"=>"lsquo,rsquo,ldquo,rdquo", "input"=>"GFM", "hard_wrap"=>false, "footnote_nr"=>1, "show_warnings"=>false, "syntax_highlighter"=>"rouge", "syntax_highlighter_opts"=>{}, "coderay"=>{}, :auto_ids=>true, :toc_levels=>"1..6", :entity_output=>"as_char", :smart_quotes=>"lsquo,rsquo,ldquo,rdquo", :input=>"GFM", :hard_wrap=>false, :footnote_nr=>1, :show_warnings=>false, :syntax_highlighter=>"rouge", :syntax_highlighter_opts=>{}, :coderay=>{}}, "title"=>"The Wall", "name"=>"Saša Stamenković", "email"=>"umpirsky@gmail.com", "url"=>"http://0.0.0.0:4000", "analytics"=>"UA-6935870-12", "disqus-shortname"=>"umpirsky", "compress_html"=>{"clippings"=>["html", "div", "p", "ul", "td", "h1", "h2", "h3", "h4", "link", "meta", "footer", "nav", "img", "header", "hr", "br", "head", "style", "li", "ul", "ol", "time", "main", "script", "title"], "comments"=>["<!-- ", " -->"], "endings"=>["all"], "ignore"=>{"envs"=>["local"]}, "blanklines"=>false, "profile"=>false, "startings"=>[]}, "jekyll-crosspost_to_medium"=>{"text"=>"<p><i>Originally published on <a href=\\\"{{ url }}\\\" rel=\\\"canonical\\\">The Wall</a>.</i></p>"}, "sass"=>{"style"=>"compressed"}, "livereload_port"=>35729, "serving"=>true, "watch"=>true, "related_posts"=>nil}
http://0.0.0.0:4000
<p><i>Originally published on <a href=\"{{ url }}\" rel=\"canonical\">The Wall</a>.</i></p>
http://0.0.0.0:4000/2018/02/24/list-of-all-countries.html
<p><i>Originally published on <a href=\"http://0.0.0.0:4000/2018/02/24/list-of-all-countries.html\" rel=\"canonical\">The Wall</a>.</i></p>
END

Looks like url config is not correctly processed or configured.

I guess images don't work for the same reason.

Do you have url set in your _config.yml?

In the plugin:

url = "#{@site.config['url']}#{post.url}"

@aarongustafson I shared my config in the issue description. Yes, I have it. I also shared debug data, url is http://0.0.0.0:4000 for some reason, and not http://wall.umpirsky.com like I configured.

I will check out your repo and see if I can debug further. I’ve been using it for quite some time now and never ran into this issue.

@aarongustafson Thanks, here is the steps to setup:

  • git clone git@github.com:umpirsky/wall.git
  • cd wall
  • git checkout medium
  • cp .env.dist .env
  • Add your values to .env file.
  • docker-compose up

I think I figured it out: You’re running it in Docker with jekyll serve which (I think) overrides the site’s URL config. I built the Docker instance and then started up the bash console inside of Docker using

docker-compose run site bash

And then ran bundle exec jekyll build (with my Medium access tokens in place) and it worked.

Worked, thanks!