Add missing meta description to profiles, some other SEO stuff (#6706)

- Add missing meta description to profiles
- Add canonical rel link to landing page
- Remove linebreaks from title tags
- Add username to profile title
- Add toots/following/followers to profile description tags
- Add next/prev rel links to profiles
- Do not index follower/following variants of profiles
This commit is contained in:
Eugen Rochko 2018-03-09 00:35:07 +01:00 committed by GitHub
parent 188aa3ea50
commit ff44b2e92d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 16 deletions

View file

@ -8,6 +8,27 @@ module StreamEntriesHelper
account.display_name.presence || account.username account.display_name.presence || account.username
end end
def account_description(account)
prepend_str = [
[
number_to_human(account.statuses_count, strip_insignificant_zeros: true),
t('accounts.posts'),
].join(' '),
[
number_to_human(account.following_count, strip_insignificant_zeros: true),
t('accounts.following'),
].join(' '),
[
number_to_human(account.followers_count, strip_insignificant_zeros: true),
t('accounts.followers'),
].join(' '),
].join(', ')
[prepend_str, account.note].join(' · ')
end
def stream_link_target def stream_link_target
embedded_view? ? '_blank' : nil embedded_view? ? '_blank' : nil
end end

View file

@ -2,6 +2,7 @@
= site_hostname = site_hostname
- content_for :header_tags do - content_for :header_tags do
%link{ rel: 'canonical', href: about_url }/
%script#initial-state{ type: 'application/json' }!= json_escape(@initial_state_json) %script#initial-state{ type: 'application/json' }!= json_escape(@initial_state_json)
= javascript_pack_tag 'about', integrity: true, crossorigin: 'anonymous' = javascript_pack_tag 'about', integrity: true, crossorigin: 'anonymous'
= render partial: 'shared/og' = render partial: 'shared/og'

View file

@ -1,7 +1,7 @@
= opengraph 'og:url', url = opengraph 'og:url', url
= opengraph 'og:site_name', site_title = opengraph 'og:site_name', site_title
= opengraph 'og:title', [yield(:page_title).strip.presence, site_title].compact.join(' - ') = opengraph 'og:title', [yield(:page_title).strip.presence, site_title].compact.join(' - ')
= opengraph 'og:description', account.note = opengraph 'og:description', account_description(account)
= opengraph 'og:image', full_asset_url(account.avatar.url(:original)) = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
= opengraph 'og:image:width', '120' = opengraph 'og:image:width', '120'
= opengraph 'og:image:height', '120' = opengraph 'og:image:height', '120'

View file

@ -1,7 +1,9 @@
- content_for :page_title do - content_for :page_title do
= display_name(@account) = "#{display_name(@account)} (@#{@account.username})"
- content_for :header_tags do - content_for :header_tags do
%meta{ name: 'description', content: account_description(@account) }/
- if @account.user&.setting_noindex - if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/ %meta{ name: 'robots', content: 'noindex' }/
@ -9,6 +11,11 @@
%link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/ %link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/
%link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@account) }/ %link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@account) }/
- if @older_url
%link{ rel: 'next', href: @older_url }/
- if @newer_url
%link{ rel: 'prev', href: @newer_url }/
= opengraph 'og:type', 'profile' = opengraph 'og:type', 'profile'
= render 'og', account: @account, url: short_account_url(@account, only_path: false) = render 'og', account: @account, url: short_account_url(@account, only_path: false)
@ -42,6 +49,6 @@
- if @newer_url || @older_url - if @newer_url || @older_url
.pagination .pagination
- if @older_url - if @older_url
= link_to safe_join([fa_icon('chevron-left'), t('pagination.older')], ' '), @older_url, class: 'older', rel: 'older' = link_to safe_join([fa_icon('chevron-left'), t('pagination.older')], ' '), @older_url, class: 'older', rel: 'next'
- if @newer_url - if @newer_url
= link_to safe_join([t('pagination.newer'), fa_icon('chevron-right')], ' '), @newer_url, class: 'newer', rel: 'newer' = link_to safe_join([t('pagination.newer'), fa_icon('chevron-right')], ' '), @newer_url, class: 'newer', rel: 'prev'

View file

@ -2,9 +2,7 @@
= t('accounts.people_who_follow', name: display_name(@account)) = t('accounts.people_who_follow', name: display_name(@account))
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/ %meta{ name: 'robots', content: 'noindex' }/
= render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false) = render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false)
= render 'accounts/header', account: @account = render 'accounts/header', account: @account

View file

@ -2,9 +2,7 @@
= t('accounts.people_followed_by', name: display_name(@account)) = t('accounts.people_followed_by', name: display_name(@account))
- content_for :header_tags do - content_for :header_tags do
- if @account.user&.setting_noindex
%meta{ name: 'robots', content: 'noindex' }/ %meta{ name: 'robots', content: 'noindex' }/
= render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false) = render 'accounts/og', account: @account, url: account_followers_url(@account, only_path: false)
= render 'accounts/header', account: @account = render 'accounts/header', account: @account

View file

@ -11,11 +11,7 @@
%meta{ name: 'theme-color', content: '#282c37' }/ %meta{ name: 'theme-color', content: '#282c37' }/
%meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/ %meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/
%title< %title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp, ' - ', title]) : title
- if content_for?(:page_title)
= yield(:page_title)
= ' - '
= title
= stylesheet_pack_tag 'common', media: 'all' = stylesheet_pack_tag 'common', media: 'all'
= stylesheet_pack_tag current_theme, media: 'all' = stylesheet_pack_tag current_theme, media: 'all'