Link to forum on Twitter with no image (remove meta tags)

Would this be possible? I’ve been appending a link to the forum home page to tweets but would rather do without the image. I guess the opengraph image Is used (currently I haven’t uploaded one).

Is there a way of getting rid of the image altogether? None of my topics will have images either so I’d be happy to do this site-wide.

As a second best, what if upload a really small logo to opengraph image? Would Twitter just resize it to be the same as it is now?


I’ve had a look and just need to get rid of:

<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="filename.png">

Would this be possible somehow?

Yes, it is possible :slight_smile:

You can write a plugin to override the crawlable_meta_data method in this module:

Everything is possible with software … very little with computer software is “not possible” :slight_smile:

You can also, more-than-likely, just match and delete with pups but that is, for the most part, frowned upon by the meta team.

1 Like

Thanks. I will look into how to create a Discourse plugin and how Ruby works!

In general, though, will I have to replace the whole method, and look out for relevant changes on every Discourse upgrade?

Creating a plugin seems like something I won’t have time for in the short term. What would happen if I found the relevant file in my Discourse installation and just commented out these lines each time I upgrade?

    if opts[:twitter_summary_large_image].present?
      result << tag(:meta, name: 'twitter:card', content: "summary_large_image")
      result << tag(:meta, name: "twitter:image", content: opts[:twitter_summary_large_image])
    elsif opts[:image].present?
      result << tag(:meta, name: 'twitter:card', content: "summary")
      result << tag(:meta, name: "twitter:image", content: opts[:image])
      result << tag(:meta, name: 'twitter:card', content: "summary")

When you upgrade these files are overwritten when the Discourse repo is pulled into your workspace (folder); so you cannot simply “comment out” lines in a file because those files will be overwritten.

Although there are myriad ways to do things in the world of tech possibilities, the generally accepted way to modify the core is via a plugin, as mentioned earlier.

Generally speaking, in this case you would override the method in that module with your code.

Best to create a development environment because you do not want to break your production application.

This is a relatively simple plugin to write, but since you are not yet experienced with this style of development, you might consider posting over in #marketplace and asking one of the well-heeled developers who make a living developing plugins to help you.

Otherwise, you can set up a development environment and have fun learning to develop Discourse plugins.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.