How to add Twitter card image to post created in blogdown - twitter

I created a post in blogdown from a .Rmd file. The header of the file includes:
---
title: Social assistance and unemployment duration in Alberta
author: Blake Shaffer
date: '2018-11-30'
slug: caseload-duration
categories: []
tags: []
twitterImg: post/2018-11-29-caseload-duration-files/figure-html/unnamed-chunk-5-1.png
header:
caption: ''
image: '/caseload-duration-banner.png'
---
But when I tweet a link to the post, the image does not appear:
I am using blogdown via RStudio, and the hugo/gcashen-academic theme.
Is there something I am missing?

I ran your post though the Twitter Card Validator - https://cards-dev.twitter.com/validator
It seems to work - the image is displayed. Looking through the source for https://www.blakeshaffer.ca/post/caseload-duration/ I notice one possible problem on this line:
<meta name="twitter:image" content="http://blakeshaffer.ca/post/2018-11-29-caseload-duration_files/figure-html/unnamed-chunk-5-1.png" >
You should make sure that the image is referenced using https rather than just http

Related

Github Pages redirect only works locally, but not on the remote Github server (got 404)

When I click on the tags on the right of my Github pages, it always give me a 404 page. However, when I preview it locally, the redirect seem to work just fine:
I wonder if it has something to do with my _config.yml. I have tried different url and baseurl strings, but still couldn't resolve it.
(Note: This theme was adopted from Chirpy)
Thanks!
Part of my config.yml:
title: Changyu Yan
url: 'https://changyuyan.github.io'
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: ''
timezone: America/Los_Angeles
google_analytics:
id: ''
pv:
# The Google Analytics pageviews switch.
# DO NOT enable it unless you know how to deploy the Google Analytics superProxy.
enabled: false
# the next options only valid when `google_analytics.pv` is enabled.
proxy_url: ''
proxy_endpoint: ''
cache: false # pv data local cache, good for the users from GFW area.
# boolean type, the global switch for ToC in posts.
toc: true
paginate: 10
kramdown:
syntax_highlighter: rouge
syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options
css_class: highlight
# default_lang: console
span:
line_numbers: false
block:
line_numbers: true
start_line: 1
# DO NOT change this unless you're a Pro user on Jekyll and Web development,
# or you think you're smart enough to change other relevant URLs within this template.
permalink: /posts/:title/
collections:
tabs:
output: true
sort_by: order
defaults:
-
scope:
path: '' # An empty string here means all files in the project
type: posts
values:
layout: post
comments: true # Enable comments in posts.
toc: true # Display TOC column in posts.
breadcrumb:
-
label: Posts
url: /
-
scope:
path: _drafts
values:
comments: false
-
scope:
path: index.html
values:
breadcrumb:
-
label: Posts
-
scope:
path: tags
values:
breadcrumb:
-
label: Home
url: /
-
label: Tags
url: /tabs/tags/
-
scope:
path: categories
values:
breadcrumb:
-
label: Home
url: /
-
label: Categories
url: /tabs/categories/
-
scope:
path: ''
type: tabs # see `site.collections`
values:
layout: page
dynamic_title: true # Hide title in mobile screens.
breadcrumb:
-
label: Home
url: /
sass:
sass_dir: /assets/css
style: compressed
compress_html:
clippings: all
comments: all
endings: all
profile: false
blanklines: false
ignore:
envs: []
exclude:
- vendor
- Gemfile.lock
- Gemfile
- tools
- docs
- README.md
- LICENSE
jekyll-archives:
enabled: [categories, tags]
layouts:
category: category
tag: tag
permalinks:
tag: /tags/:name/
category: /categories/:name/
The archives are working locally and not on GitHub Pages because the jekyll-archives gem is not supported in GitHub Pages. You can see in the notes for Chirpy, under Deploy on GitHub Pages, an option for using GitHub Actions. This should allow you to run unsupported plugins (there is a good tutorial by Aneejian).
Another option is to manually build all your tag pages. You would need to create a tag directory and inside that, create all the tag files (software-engineering.html). Inside those you'd run a for loop for that tag. You have a couple of options:
{% for post in site.tags.software-engineering %}
or
{% for post in site.posts | where: 'tag', 'software-engineering' %}
There are others that may better suit your use-case.
Per the baseurl discussion, you do not need that if you do not use a project directory. If you wanted https://changyuyan.github.io/blog/tags/software-engineering/, you'd need to add baseurl: '/blog ...but it doesn't look like you want that.
Near the top of your _config.yml, set baseurl to the name of the project repo according to the instructions:
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: '/changyuyan.github.io'

How to disable manual seeking on Google Actions/Assistant Conversations - Media response?

I'm already able to play music with #assistant/conversation by using this:
conv.add(new Media({
mediaObjects: [{
name: 'Trance Track 1',
description: 'Media description',
url: 'https://my-url.de/Trance1.mp3',
image: {
large: new Image({
url: 'https://somewhere/whateverimage.jpg',
alt: 'my image here'
})
}
}],
mediaType: MediaType.Audio,
optionalMediaControls: [OptionalMediaControl.Paused, OptionalMediaControl.Stopped],
startOffset: '0s'
}));
But the user is able to seek forward/backward. How can I disable this?
TuneIn already has this. I could not find anything in the docs: https://developers.google.com/assistant/conversational/prompts-media
The answer for this issue can be found on the corresponding GitHub issue: https://github.com/actions-on-google/assistant-conversation-nodejs/issues/17
In summary:
Unfortunately, the Media response API does not support the features requested (i.e. disable seeking, prevent skip track, skip track w/ complex rule set, etc.).
To get a full overview on what features Media response provides, as well as it's limitations, please refer to our documentation:
https://developers.google.com/assistant/conversational/prompts-media
Feature request tickets have been filed internally for [these features].

How to get Twitter to recognize Angular7 meta tags in a sub page served by a route

I want my Angular7 code to take a URL that contains a route and present desired updated meta tags to Twitter so that Twitter will render the correct social card.
Following standard practices for meta tags, which includes declaring in index.html header and updating in constructors of pages loaded by routes, I can see the correct updated values in the browser console, but twitter ignores those updates and uses the first meta tags from index.html.
From index.html...
<head>
<title>My Title</title>
<!-- Other Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="#myAccountName">
<meta name="twitter:title" content="My Title">
<meta name="twitter:description" content="A detailed description of the site">
<meta name="twitter:image" content="https://www.oursite.com/welcome.png">
From app.module.ts…
import { mySubComponent } from './components/mySub/mySub.component';
...
const appRoutes: Routes = [
...
{ path: 'mySubPage', component: mySubComponent },
...
From the .ts file for the module loaded by www.oursite.com/mySubPage...
import { Router, ActivatedRoute, Params } from '#angular/router';
import { Meta, Title } from '#angular/platform-browser';
#Component({
selector: 'app-mySub',
templateUrl: './mySub.component.html',
styleUrls: ['./mySub.component.css']
})
export class mySubComponent implements OnInit {
...
constructor(
...
public meta: Meta, public title: Title) {
meta.updateTag({ name: 'twitter:card', content: 'summary_large_image' });
meta.updateTag({ name: 'twitter:site', content: '#myAccountName});
meta.updateTag({ name: 'twitter:title', content: 'My Sub Title' });
meta.updateTag({ name: 'twitter:description', content: 'The descript of the sub page' });
meta.updateTag({ name: 'twitter:image', content: 'https://www.oursite.com/mySubPageLogo.png' });
}
When I run this in the browser and manually type the full URL with the route (www.oursite.com/mySubPage, the console Inspector shows all the correct settings...
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="#myAccountName">
<meta name="twitter:title" content="My Sub Title">
<meta name="twitter:description" content="The descript of the sub page">
<meta name="twitter:image" content="https://https://www.oursite.com/mySubPageLogo.png">
But the twitter card validator set to the exact same Sub URL shows the card from the main index.html and appears to ignore the updates from the route altogether.
By the way, I did attempt all steps to flush the twitter cache, and even waited for longer than 12 hours and tried again. But I can make an update to the main tags and the change shows up, so it's not a cache issue with twitter.
This following is from https://twittercommunity.com/t/not-whitelisted-unable-to-render-or-no-image-read-this-first/62736 It looks like unless someone knows of a different approach, they are basically saying we can't serve up different cards from different angular routes from the same app domain. You only get one. Notice they spell it out in the middle...
Before posting a Cards issue, please READ the following:
If you are posting about any issue with your site, please include a
link to the publically-accessible URL where your Card markup is
visible, or we will be unable to help you.
You should also make sure that you’ve checked the items below, and
perform your own troubleshooting before asking for additional help.
Posts that indicate that none of these checks have been performed will
not be prioritised for attention.
As of early 2018, cards no longer require whitelisting (including
player cards)
The not whitelisted error message from the Validator is misleading, and almost certainly means that the tool cannot see or
find any twitter:card markup in your page.
If you see a message saying that you need to submit your card for approval, you’ve probably specified an incorrect card type in the
markup.
Please review the following if you are having other issues:
when you view the source of your page, the expected Twitter Cards meta tags 581 are shown
NB at a minimum, your page must contain at least a twitter:card meta tag specifying a valid card type 370, or suitable OpenGraph
fallback tags 170.
if you execute curl -v -A Twitterbot at the command prompt, does your page still show the twitter:card tags in the section
of the page? Does your server return a 200 response code and a valid
Content-Type header?
is your page adding the tags after it is loaded, for instance using Javascript (e.g. Angular, Meteor, Google Tags Manager)? The
crawler and validator cannot execute Javascript and the tags must be
static.
is your site accessible by the Twitterbot/1.0 user-agent? Are all the files (including image files) accessible to Twitterbot? you should
check http://your-site-url/robots.txt 646 and ensure that it allows
access to our crawler. If your images are on a different domain, also
make sure you check the robots.txt file for that domain.
are you using a Wordpress (or other CMS/blogging platform) plugin? We provide our own official Wordpress plugin 614, but cannot easily
provide support for those built by third parties. Check that the
configuration includes all of the required tags. Avoid using multiple
plugins at the same time, as tags will override one another.
are you putting the top-level site URL into the Validator, or the specific URL where your markup is present? you’ll need to make sure
that you provide a link to where your Card markup is visible in the
page.
are you using a supported 370 Card type? Product, Gallery and Photo cards were deprecated in mid-2015 128. Is the card type spelled
correctly, or is there a typo?
if your image is not showing, is it accessible on a URL that is not blocked by your robots.txt file? Does it conform to our size
constraints? Are you using an absolute and full URL (including the
http protocol piece), not a relative one?
if you see a validator message about Fetching the page failed because other errors or similar, check your SSL configuration. The
certificate and server name must match (or be aliased to match) due to
Java security constraints. More in this thread 220.
are you using a fully qualified DNS domain name? The crawler does not support dotted IP addresses as domain references, and cannot
access localhost.
There is much more Troubleshooting 302 information on our Developer
site.
Looks like there's no work-around for Angular7 at this time. Apparently there can be only one card, served up statically from on index.html per angular domain name.
Are you using a firebase as a BaaS? If so I was able to get twitter to render cards by doing exactly what you were doing above(setting up a service or inserting Meta tags into components). this lesson helped me out https://fireship.io/lessons/angular-universal-firebase/ , but base on my issue besides it having anything to do with being firebase app, my universal would not serve into the browser under app-root. I did not have to render any meta tags in my default index.html. Check the tutorial above and see if that helps out your issue at all.
https://angular.io/guide/universal
// Sub-Component
import { Component, OnInit } from '#angular/core';
import { Title, Meta } from '#angular/platform-browser';
#Component({
selector: 'app-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.scss']
})
export class AboutComponent implements OnInit {
data = {
name: 'Michael Jordan',
bio: 'Former baseball player',
image: ''
};
constructor(private title: Title, private meta: Meta) {}
ngOnInit() {
this.title.setTitle(this.data.name);
this.meta.addTags([
{ name: 'twitter:card', content: 'summary' },
{ name: 'og:url', content: '/about' },
{ name: 'og:title', content: this.data.name },
{ name: 'og:description', content: this.data.bio },
{ name: 'og:image', content: this.data.image }
]);
}
}

Share on LinkedIn with og

I have rails app. I added og tags for Facebook, google +, and Vkontakte. And I need to add possibility to share to LinkedIn too. But I don't understand why LinkedIn don't pick my OG tags.
My html:
= tag :meta, property: 'og:url', content: 'https://myapp.com/app'
= tag :meta, property: 'og:title', content: 'MyApp'
= tag :meta, property: 'og:description', content: 'You can always find a my app !'
= tag :meta, property: 'og:image', content: "https://myapp.com#{image_path('backgrounds/desk.jpg')}"
And facebook, g+, vk works perfectly, but linked in don't fetch any information from my website.
Any advise?
I had the same problem: everything worked except for LinkedIn on our https-only website. The problem was that ServerName and ServerAlias were not set in the Apache config file (default-ssl in our case).
You can use the Twitter card validator to check your SSL-settings (https://cards-dev.twitter.com/validator), if this throws an error adjust your Apache config.
You find additional information here: SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0
and here: Making your site shareable on LinkedIn
Interesting! You made your post on March 10, 2017. Support for og: tags at LinkedIn was only officially added and released on March 23, 2017; the feature just 13 days away!
The following formats are now all supported...
<meta property='og:title' content='Title of the article"/>
<meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
<meta property='og:description' content='Description that will show in the preview"/>
<meta property='og:url' content='//www.example.com/URL of the article" />
Source: Official LinkedIn Documentation: Making Your Website Shareable on LinkedIn.
Works great for me:
If you want to verify that you have the tags in place correctly in your <head> block of HTML, try testing the page you're sharing at LinkedIn Post Inspector.

Formatting posts with the Slack api

I'm trying to create Posts with botkit using the Slack api, but I can't find any documentation on how to format a Post file in Slack.
bot.api.files.upload({
content: "# Heading",
filename: "test.md",
filetype: "post",
channels: "random"
});
Markdown formatting doesn't work for this, is there any syntax to formatting Slack Posts?
Trying with HTML the response from the created file is like this:
<document><p><document><h1>H1<\/h1><p><\/p><h2>H2<\/h2><p><\/p><h3>H3<\/h3><p><\/p><p>Text <i>italic<\/i> <b>bold<\/b> <a href="<a href=\"http:\/\/www.slack.com%22%3Elink%3C\/a%3E\">http:\/\/www.slack.com">link<\/a><\/a> <u>underline<\/u><\/p><p><\/p><p><strike>strikethrough<\/strike><\/p><p><\/p><p><code>Code Block;<\/code><\/p><\/document><\/p><\/document>
so it's escaping html tags.
Posts support markdown formatting.
E.g., try setting the following content:
# A Post Header
### Subheading
An image? ![Funny](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ4jlx3aktZVFKAkaNB7fvy67BFQuaO3HedVQ6VIXeR5OLnfbOOEbrcp-G4)
[A link to google](https://www.google.com)
* A list item
* Another list item
`a code block`
You then post with filetype="post", and get the following:
I tested and slack appears to support most markdown features but not all. Make sure to test your formatting!

Resources