Changing the Discourse "Powered by" Link (powered_by_html) for Web Crawlers

Discourse served different code for web crawlers compared to code served for users.

For web crawlers, there is a "powered by" link at the bottom of the pages crawled:

Screen Shot 2020-08-01 at 1.46.54 PM

Of course, it's nice to give back to the Discourse community with this link on each page; but for people like us to give back in many other ways, like assisting users on meta or writing plugins, we might want that link to point to our own web property.

You can do this in the container yml file.

To remove the link completely:

run:
  - exec: echo "Beginning of custom commands"
  - exec: sed -i '/powered_by_html/d' /var/www/discourse/app/views/layouts/crawler.html.erb

Or to change it, try something like this instead:

run:
  - exec: echo "Beginning of custom commands"
  - exec: sed -i '/powered-by-link/c\<p class="powered-by-link">Powered by <a href="https://www.unix.com/">UNIX.com</a>, best viewed with JavaScript enabled</p>' /var/www/discourse/app/views/layouts/crawler.html.erb

Which results in this, served to web crawlers:

Reference: