XF 2.2 Помогите с переменными hreflang

Версия XenForo
v2.2.13

ФАКЕР

Проверенные
Сообщения
820
Решения
9
Реакции
83
Баллы
730
В page_conteiner я добавил:

Код:
<link rel="alternate" hreflang="{$lang}" href="{$requestPaths.fullUri}">

В forum_view:
Код:
<xen:container var="$lang">en-US</xen:container>

В forum_list:
Код:
    <xen:container var="$lang">ru-RU</xen:container>

не работает 😟
 
Последнее редактирование:
Сейчас у меня на всех страницах прописано:

Код:
<link rel="alternate" hreflang="x-default" href="https://forum.ru/" />
<link rel="alternate" hreflang="ru" href="https://forum.ru/uzel_na_inglishe/">
<link rel="alternate" hreflang="en" href="https://forum.ru/uzel_na_russkom/">

Если перейти в какую нибудь тему, то там будет тоже самое. А нужно что бы тема отдавала нужный hreflang.
 
В шаблон forum_view вставил:
Код:
<xf:head option="metaNoindex"><meta name="robots" content="noindex" />
<xf:if is="{$forum.node_id} == 30">
<link rel="alternate" hreflang="en" href="https://forum.ru{$xf.uri}"/>
</xf:if>
</xf:head>

где 30 - это id моего узла.
открыл узел и рандомную тему в этом узле, нажал посмотреть код страницы и не увидел там hreflang 🤯🤯


upd: вставил чуть ниже и всё получилось.
теперь нужно сделать hreflang для тем из определенных узлов. я хз в какую сторону копать
 
Последнее редактирование:
теперь нужно сделать hreflang для тем из определенных узлов. я хз в какую сторону копать
Пример для добавления в темы из разделов 7,8,5,6 - заменить на своё.
Шаблон: thread_view

Код:
<xf:if is="{{ in_array($thread.Forum.Node.node_id, [7,8,5,6]) }}">
    <xf:head option="lang">
        <link rel="alternate" hreflang="en" href="{{ $xf.fullUri }}"/>
    </xf:head>
</xf:if>

Все изменения через систему модификаций.
 
recruty мой thread_view:
Код:
<xf:title page="{$page}">{{ prefix('thread', $thread, 'escaped') }}{$thread.title}</xf:title>
<script>
//блок клика мышью
document.oncontextmenu = cmenu; function cmenu() { return false; }
</script>
<xf:h1>{{ prefix('thread', $thread) }}{$thread.title}</xf:h1>

<xf:if is="!$thread.isSearchEngineIndexable()">
    <xf:head option="metaNoindex"><meta name="robots" content="noindex" />
    

    
    
    
    
    </xf:head>
</xf:if>

<xf:if is="{$xpressView}">
    <xf:set var="$uix_condensed" value="1" />
</xf:if>

<xf:pageaction>
    <xf:if is="$thread.canReply()">
        <xf:button href="{{ link('threads/reply', $thread) }}" class="button--cta uix_quickReply--button" icon="write">{{ phrase('reply') }}</xf:button>
    </xf:if>
</xf:pageaction>

<xf:description meta="false">
    <ul class="listInline listInline--bullet">
        <li>
            <xf:fa icon="fa-user" title="{{ phrase('thread_starter')|for_attr }}" />
            <span class="u-srOnly">{{ phrase('thread_starter') }}</span>

            <xf:username user="{$thread.User}" defaultname="{$thread.username}" class="u-concealed" />
        </li>
        <li>
            <xf:fa icon="fa-clock" title="{{ phrase('start_date')|for_attr }}" />
            <span class="u-srOnly">{{ phrase('start_date') }}</span>

            <a href="{{ link('threads', $thread) }}" class="u-concealed"><xf:date time="{$thread.post_date}" /></a>
        </li>
        <xf:if is="$xf.options.enableTagging AND ($thread.canEditTags() OR $thread.tags)">
            <li>
                <xf:macro template="tag_macros" name="list"
                    arg-tags="{$thread.tags}"
                    arg-tagList="tagList--thread-{$thread.thread_id}"
                    arg-editLink="{{ $thread.canEditTags() ? link('threads/tags', $thread) : '' }}" />
                
                
                
                
            
                
                
            </li>
        </xf:if>
    </ul>
</xf:description>

<xf:set var="$fpSnippet" value="{{ snippet($firstPost.message, 0, {'stripBbCode': true}) }}" />

<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$fpSnippet}"
    arg-shareUrl="{{ link('canonical:threads', $thread) }}"
    arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />

<xf:page option="ldJsonHtml">
    <xf:extension name="structured_data_extra_params" value="{{ [] }}" />
    <xf:extension name="structured_data">
        <xf:set var="$ldJson"
            value="{{ $thread.getLdStructuredData($firstPost, $page, extension_value('structured_data_extra_params')) }}"
        />
        <xf:if is="$ldJson">
            <script type="application/ld+json">
                {$ldJson|json(true)|raw}
            </script>
        </xf:if>
    </xf:extension>
</xf:page>

<xf:extension name="content_top"></xf:extension>
<!--[XF:content_top]-->

<xf:if is="$pendingApproval">
    <div class="blockMessage blockMessage--important">{{ phrase('content_submitted_displayed_pending_approval') }}</div>
</xf:if>

<xf:if is="$thread.prefix_id">
    <xf:if contentcheck="true">
        <div class="blockMessage blockMessage--alt blockMessage--small blockMessage--close">
            <xf:contentcheck>{{ prefix_description('thread', $thread.prefix_id) }}</xf:contentcheck>
        </div>
    </xf:if>
</xf:if>

<xf:macro template="forum_macros" name="forum_page_options" arg-forum="{$forum}" arg-thread="{$thread}" />

<xf:breadcrumb source="$forum.getBreadcrumbs()" />

<xf:if is="$canInlineMod OR $thread.canUseInlineModeration()">
    <xf:js src="xf/inline_mod.js" min="1" />
</xf:if>

<xf:extension name="above_messages"></xf:extension>
<xf:ad position="thread_view_above_messages" arg-thread="{$thread}" />
<xf:widgetpos id="thread_view_above_messages" context-thread="{$thread}" />

<xf:set var="$threadActionsHtml">
    <xf:extension name="thread_actions">
        <xf:if contentcheck="true">
            <div class="block-outer-opposite">
                <div class="buttonGroup">
                <xf:contentcheck>
                    <xf:extension name="thread_action_buttons">
                        <xf:if is="$canInlineMod">
                            <xf:macro template="inline_mod_macros" name="button" />
                        </xf:if>
                        <xf:if is="$thread.discussion_state == 'deleted' AND $thread.canUndelete()">
                            <xf:button href="{{ link('threads/undelete', $thread) }}" class="button--link" overlay="true">
                                {{ phrase('undelete') }}
                            </xf:button>
                        </xf:if>
                        <xf:if is="$thread.canApproveUnapprove() AND $thread.discussion_state == 'moderated'">
                            <xf:button href="{{ link('threads/approve', $thread) }}" class="button--link" overlay="true">
                                {{ phrase('approve') }}
                            </xf:button>
                        </xf:if>
                        <xf:if is="$xf.visitor.user_id AND $thread.isUnread()">
                            <xf:button href="{{ ($firstUnread AND $isSimpleDateDisplay) ? ('#post-' . $firstUnread.post_id) : link('threads/unread', $thread, {'new': 1}) }}"
                                class="button--link"
                                data-xf-click="scroll-to"
                                data-silent="true">
                                    {{ phrase('jump_to_new') }}
                            </xf:button>
                        </xf:if>
                        <xf:if is="$thread.canWatch()">
                            <xf:button href="{{ link('threads/watch', $thread) }}" class="button--link"
                                data-xf-click="switch-overlay"
                                data-sk-watch="{{ phrase('watch') }}"
                                data-sk-unwatch="{{ phrase('unwatch') }}">
                                <xf:if is="{$thread.Watch.{$xf.visitor.user_id}}">
                                    {{ phrase('unwatch') }}
                                <xf:else />
                                    {{ phrase('watch') }}
                                </xf:if>
                            </xf:button>
                        </xf:if>

                        <xf:if contentcheck="true">
                            <div class="buttonGroup-buttonWrapper">
                                <xf:button class="button--link menuTrigger" data-xf-click="menu" aria-expanded="false" aria-haspopup="true" title="{{ phrase('more_options') }}">&#8226;&#8226;&#8226;</xf:button>
                                <div class="menu" data-menu="menu" aria-hidden="true">
                                    <div class="menu-content">
                                        <h4 class="menu-header">{{ phrase('more_options') }}</h4>
                                        <xf:contentcheck>
                                            <!--[XF:thread_tools_menu:top]-->
                                            <xf:if is="$thread.canEdit()">
                                                <a href="{{ link('threads/edit', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('edit_thread') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canChangeType() AND count($creatableThreadTypes) > 1">
                                                <a href="{{ link('threads/change-type', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('change_thread_type') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canLockUnlock()">
                                                <a href="{{ link('threads/quick-close', $thread) }}"
                                                    class="menu-linkRow"
                                                    data-xf-click="switch"
                                                    data-menu-closer="true">

                                                    <xf:if is="$thread.discussion_open">
                                                        {{ phrase('lock_thread') }}
                                                    <xf:else />
                                                        {{ phrase('unlock_thread') }}
                                                    </xf:if>
                                                </a>
                                            </xf:if>
                                            <xf:if is="$thread.canStickUnstick()">
                                                <a href="{{ link('threads/quick-stick', $thread) }}"
                                                    class="menu-linkRow"
                                                    data-xf-click="switch"
                                                    data-menu-closer="true">

                                                    <xf:if is="$thread.sticky">
                                                        {{ phrase('unstick_thread') }}
                                                    <xf:else />
                                                        {{ phrase('stick_thread') }}
                                                    </xf:if>
                                                </a>
                                            </xf:if>
                                            <xf:if is="$thread.canCreatePoll()">
                                                <a href="{{ link('threads/poll/create', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('create_poll') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canDelete('soft')">
                                                <a href="{{ link('threads/delete', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('delete_thread') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canMove()">
                                                <a href="{{ link('threads/move', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('move_thread') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canReplyBan()">
                                                <a href="{{ link('threads/reply-bans', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('manage_reply_bans') }}</a>
                                            </xf:if>
                                            <xf:if is="$thread.canViewModeratorLogs()">
                                                <a href="{{ link('threads/moderator-actions', $thread) }}" data-xf-click="overlay" class="menu-linkRow">{{ phrase('moderator_actions') }}</a>
                                            </xf:if>
                                            <!--[XF:thread_tools_menu:before_footer]-->
                                            <xf:if is="$thread.canUseInlineModeration()">
                                                <div class="menu-footer"
                                                    data-xf-init="inline-mod"
                                                    data-type="thread"
                                                    data-href="{{ link('inline-mod') }}"
                                                    data-toggle=".js-threadInlineModToggle">
                                                    <xf:checkbox>
                                                        <xf:option class="js-threadInlineModToggle" value="{$thread.thread_id}">{{ phrase('select_for_moderation') }}</xf:option>
                                                    </xf:checkbox>
                                                </div>
                                            </xf:if>
                                            <!--[XF:thread_tools_menu:bottom]-->
                                        </xf:contentcheck>
                                    </div>
                                </div>
                            </div>
                        </xf:if>
                    </xf:extension>
                </xf:contentcheck>
                </div>
            </div>
        </xf:if>
    </xf:extension>
</xf:set>

<xf:set var="$postSortFilterHtml">
    <xf:extension name="post_sort_filter">
        <xf:if is="($posts is not empty OR $filters)">
            <xf:if contentcheck="true">
                <div class="tabs tabs--standalone tabs--standalone--small tabs--standalone--inline">
                <xf:contentcheck>
                    <xf:if is="$availableSorts AND count($availableSorts) > 1">
                        <xf:foreach loop="$availableSorts" key="$sortKey" value="$null">
                            <a href="{{ link('threads', $thread, $pageNavFilters|replace({'order': $sortKey == $defaultOrder ? null : $sortKey})) }}"
                                class="tabs-tab {{ $sortKey == $effectiveOrder ? 'is-active' : '' }}"
                                rel="nofollow">
                                {{ phrase_dynamic('thread_sort.' . $sortKey) }}
                            </a>
                        </xf:foreach>
                    </xf:if>
                    <xf:extension name="post_sort_filter_end"></xf:extension>
                </xf:contentcheck>
                </div>
            </xf:if>
        </xf:if>
    </xf:extension>
</xf:set>

<xf:if is="$isFirstPostPinned">
    <xf:extension name="pinned_block_before"></xf:extension>

    <xf:extension name="pinned_block_classes" value="" />
    <div class="block block--messages {{ extension_value('pinned_block_classes') }}"
        data-xf-init="lightbox{{ $xf.options.selectQuotable ? ' select-to-quote' : '' }}"
        data-message-selector=".js-post"
        data-lb-id="thread-{$thread.thread_id}">
        <xf:extension name="pinned_outer_before">
            <xf:macro name="thread_status" arg-thread="{$thread}" arg-wrapperClass="block-outer" />

            <div class="block-outer"><xf:trim>
                {$threadActionsHtml}
            </xf:trim></div>

            <xf:macro name="thread_custom_fields_status"
                arg-thread="{$thread}"
                arg-forum="{$forum}"
                arg-wrapperClass="block-outer" />
        </xf:extension>

        <div class="block-container">
            <div class="block-body">
                <xf:extension name="pinned_body">
                    <xf:macro name="{{ $templateOverrides.pinned_first_post_macro ?: 'post_macros::post' }}"
                        arg-post="{$pinnedPost}"
                        arg-thread="{$thread}"
                        arg-highlightedPosts="{$highlightedPosts}"
                        args="{$templateOverrides.pinned_first_post_macro_args}" />
                </xf:extension>
            </div>
        </div>

        <xf:extension name="pinned_outer_after"></xf:extension>
    </div>
</xf:if>

<xf:extension name="above_messages_below_pinned"></xf:extension>

<xf:extension name="message_block_classes" value="block--messages" />
<div class="block {{ extension_value('message_block_classes') }}" data-xf-init="{{ $canInlineMod ? 'inline-mod' : '' }}" data-type="post" data-href="{{ link('inline-mod') }}" data-search-target="*">

    <span class="u-anchorTarget" id="posts"></span>

    <xf:if is="!$isFirstPostPinned">
        <xf:macro name="thread_status" arg-thread="{$thread}" arg-wrapperClass="block-outer" />
    </xf:if>

    <div class="block-outer"><xf:extension name="messages_block_outer"><xf:trim>
        <xf:pagenav
            page="{$page}" perpage="{$perPage}" total="{$totalPosts}"
            link="threads" data="{$thread}" params="{$pageNavFilters}" hash="{$pageNavHash}"
            wrapperclass="block-outer-main" />

            <xf:if is="!$isFirstPostPinned">
                {$threadActionsHtml}
            </xf:if>

            <xf:if contentcheck="true">
                <div class="block-outer-opposite">
                    <xf:contentcheck>{$postSortFilterHtml}</xf:contentcheck>
                </div>
            </xf:if>
    </xf:trim></xf:extension></div>

    
                        
    
    
    <xf:extension name="messages_block_outer_secondary"></xf:extension>

    <xf:if is="!$isFirstPostPinned">
        <xf:macro name="thread_custom_fields_status"
            arg-thread="{$thread}"
            arg-forum="{$forum}"
            arg-wrapperClass="block-outer" />
    </xf:if>

    <div class="block-container lbContainer"
        data-xf-init="lightbox{{ $xf.options.selectQuotable ? ' select-to-quote' : '' }}"
        data-message-selector=".js-post"
        data-lb-id="thread-{$thread.thread_id}"
        data-lb-universal="{$xf.options.lightBoxUniversal}">

        <div class="block-body js-replyNewMessageContainer">
            <xf:if is="$posts is not empty">
                <xf:foreach loop="$posts" value="$post">
        
                    
                    

                    
                    
<xf:extension name="messages_block_body_before_post"></xf:extension>
        


                    <xf:if is="$post.message_state == 'deleted'">
                        <xf:macro name="{{ $templateOverrides.post_deleted_macro ?: 'post_macros::post_deleted' }}"
                            arg-post="{$post}"
                            arg-thread="{$thread}"
                            args="{$templateOverrides.post_deleted_macro_args}" />
                    <xf:else />
                        <xf:macro name="{{ $templateOverrides.post_macro ?: 'post_macros::post' }}"
                            arg-post="{$post}"
                            arg-thread="{$thread}"
                            arg-highlightedPosts="{$highlightedPosts}"
                            args="{$templateOverrides.post_macro_args}"
                                                        arg-uix_condensed="{$uix_condensed}" />
                    </xf:if>

                    <xf:extension name="messages_block_body_after_post"></xf:extension>
                
                <xf:if is="{$post.position} == 0">
    <xf:widget key="register_please" />
    <xf:widget key="register_please_eng" />   
    <xf:widget key="knopka_hochesh_obshatsiya" />               
</xf:if>
                    
                    
<xf:if is="$xf.visitor.user_id == $thread.user_id">

    <xf:widget key="knopka_prodvca_v_teme" />

</xf:if>               
            
                    
                    
                    
                    

                </xf:foreach>
            <xf:else />
                <xf:if is="$filters">
                    <div class="message">
                        <div class="message-inner">
                            <div class="message-cell">
                                {{ phrase('there_no_posts_matching_your_filters') }}
                            </div>
                        </div>
                    </div>
                </xf:if>
            </xf:if>
        </div>
    </div>

    <xf:if contentcheck="true">
        <div class="block-outer block-outer--after">
            <xf:contentcheck>
                <xf:pagenav
                    page="{$page}" perpage="{$perPage}" total="{$totalPosts}"
                    link="threads" data="{$thread}" params="{$pageNavFilters}" hash="{$pageNavHash}"
                    wrapperclass="block-outer-main" />

                <xf:showignored wrapperclass="block-outer-opposite" />
                <xf:if is="
                    !$thread.canReply()
                    AND !$thread.canReplyPreReg()
                    AND $thread.discussion_state == 'visible'
                    AND $thread.discussion_open
                ">
                    <div class="block-outer-opposite">
                        <xf:if is="$xf.visitor.user_id">
                            <span class="button button--wrap is-disabled">
                                {{ phrase('no_permission_to_reply') }}
                                <!-- this is not interactive so shouldn't be a button element -->
                            </span>
                        <xf:else />
                            <xf:button href="{{ link('login') }}" class="button--link button--wrap" overlay="true">
                                {{ phrase('log_in_or_register_to_reply') }}
                            </xf:button>
                        </xf:if>
                    </div>
                </xf:if>
            </xf:contentcheck>
        </div>
    </xf:if>

    <xf:macro name="thread_status" arg-thread="{$thread}" arg-wrapperClass="block-outer block-outer--after" />
</div>

<xf:ad position="thread_view_below_messages" arg-thread="{$thread}" />
<xf:extension name="below_messages"></xf:extension>
<xf:widgetpos id="thread_view_below_messages" context-thread="{$thread}" />

<xf:set var="$isPreRegReply" value="{{ $thread.canReplyPreReg() }}" />
<xf:if is="$thread.canReply() OR $isPreRegReply">
    <xf:form action="{{ link('threads/add-reply', $thread) }}"
        ajax="true"
        draft="{{ link('threads/draft', $thread) }}"
        class="block js-quickReply"
        data-xf-init="attachment-manager quick-reply{{ ($xf.visitor.isShownCaptcha() AND !$isPreRegReply) ? ' guest-captcha' : '' }}"
        data-message-container="div[data-type='post'] .js-replyNewMessageContainer">

        <xf:js src="xf/message.js" min="1" />

        <div class="block-container">
            <div class="block-body">
                <xf:macro template="quick_reply_macros" name="body"
                    arg-message="{$thread.draft_reply.message}"
                    arg-attachmentData="{$attachmentData}"
                    arg-forceHash="{$thread.draft_reply.attachment_hash}"
                    arg-messageSelector=".js-post"
                    arg-multiQuoteHref="{{ link('threads/multi-quote', $thread) }}"
                    arg-multiQuoteStorageKey="multiQuoteThread"
                    arg-lastDate="{$lastPost.post_date}"
                    arg-lastKnownDate="{$thread.last_post_date}"
                    arg-loadExtra="{$isSimpleDateDisplay}"
                    arg-showGuestControls="{{ !$isPreRegReply }}"
                    arg-previewUrl="{{ link('threads/reply-preview', $thread) }}"/>
            </div>
        </div>
    </xf:form>
</xf:if>



<xf:widgetpos id="thread_view_below_quick_reply" context-thread="{$thread}" />

<xf:extension name="below_quick_reply"></xf:extension>

<div class="blockMessage blockMessage--none">
    <xf:macro template="share_page_macros" name="buttons" arg-iconic="{{ true }}" arg-label="{{ phrase('share:') }}" />
</div>

<xf:widget key="users_bloks_unregistered" />

<xf:widget key="users_bloks_unregistered_eng" />

<xf:if is="{$thread.thread_id} == 30234">
<xf:widget key="seo_text_30234" />
</xf:if>

<xf:if is="{$thread.thread_id} == 27500">
<xf:widget key="seo_text_27500" />
</xf:if>

<xf:if is="{$thread.thread_id} == 29979">
<xf:widget key="seo_text_29979" />
</xf:if>


<xf:if is="$xf.visitor.Profile.custom_fields.tip_akkaunta == 2">
<xf:widget key="pokupatel_posmotri_eshe" />
</xf:if>


<xf:extension name="below_share"></xf:extension>

<xf:macro name="thread_status" arg-thread="!" arg-wrapperClass="">
    <xf:if contentcheck="true">
        <div class="{$wrapperClass}">
            <dl class="blockStatus">
                <dt>{{ phrase('status') }}</dt>
                <xf:contentcheck>
                    <xf:if is="$thread.discussion_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$thread.DeletionLog}" />
                        </dd>
                    <xf:elseif is="$thread.discussion_state == 'moderated'" />
                        <dd class="blockStatus-message blockStatus-message--moderated">
                            {{ phrase('awaiting_approval_before_being_displayed_publicly') }}
                        </dd>
                    </xf:if>
                    <xf:if is="!$thread.discussion_open">
                        <dd class="blockStatus-message blockStatus-message--locked">
                            {{ phrase('not_open_for_further_replies') }}
                        </dd>
                    </xf:if>
                </xf:contentcheck>
            </dl>
        </div>
    </xf:if>
</xf:macro>

<xf:macro name="thread_custom_fields_status" arg-thread="!" arg-forum="!" arg-wrapperClass="">
    <div class="{$wrapperClass} js-threadStatusField"><xf:trim>
        <xf:if contentcheck="true">
            <div class="blockStatus blockStatus--info">
                <xf:contentcheck>
                    <xf:macro template="custom_fields_macros" name="custom_fields_view"
                        arg-type="threads"
                        arg-group="thread_status"
                        arg-onlyInclude="{$forum.field_cache}"
                        arg-set="{$thread.custom_fields}"
                        arg-wrapperClass="blockStatus-message" />
                </xf:contentcheck>
            </div>
        </xf:if>
    </xf:trim></div>
</xf:macro>



<xf:widgetpos id="thread_view_sidebar" context-thread="{$thread}" position="sidebar" />


куда это:
Код:
<xf:if is="{{ in_array($thread.Forum.Node.node_id, [7,8,5,6]) }}">
    <xf:head option="lang">
        <link rel="alternate" hreflang="en" href="{{ $xf.fullUri }}"/>
    </xf:head>
</xf:if>

Вставлять?
 
recruty
Спасибо! Открыл код темы из узла с id 20 и увидел:
Код:
<link rel="alternate" hreflang="en" href="https://forum.ru/threads/nazvanie-temy" />
Но ведь hreflang ведь должны быть и на альтернативном языке (например ru).

То есть на странице с темой должно быть:
Код:
<link rel="alternate" hreflang="en" href="https://forum.ru/threads/nazvanie-temy/">
<link rel="alternate" hreflang="ru" href="https://forum.ru/threads/nazvanie-temy_na_russkom/">

То есть альтернатива этой страницы.

Или ошибаюсь? Обычно ведь в hreflang пишется и основной язык и альтернативный.
 
Последнее редактирование:
Код:
<xf:if is="{{ in_array($thread.Forum.Node.node_id, [3]) }}">
    <xf:head option="lang">
        <link rel="alternate" hreflang="{{ $xf.language.language_code }}" href="{{ $xf.fullUri }}"/>
    </xf:head>
</xf:if>

Можете сделать так, итог: <link rel="alternate" hreflang="en-US" href="http://xf.localhost/index.php?threads/1.1/">
 
Последнее редактирование:
То есть на странице с темой должно быть:
Кто сказал? Нигде такого не видел

Можно попробовать сделать что-то, если у вас ссылки выглядят так: forum.com/ru/ и forum.com/en/, в данном случае можно будет реализовать hreflang.
 
Последнее редактирование:
Кто сказал? Нигде такого не видел
Ну вот гугл говорит:

Или вот это:
Код:
<head>
 <title>Widgets, Inc</title>
  <link rel="alternate" hreflang="en-gb"
       href="https://en-gb.example.com/page.html" />
  <link rel="alternate" hreflang="en-us"
       href="https://en-us.example.com/page.html" />
  <link rel="alternate" hreflang="en"
       href="https://en.example.com/page.html" />
  <link rel="alternate" hreflang="de"
       href="https://de.example.com/page.html" />
 <link rel="alternate" hreflang="x-default"
       href="https://www.example.com/" />
</head>

Должно быть только на главной?
А в конкретной теме должно быть только указание языка страницы?
Блин я уже запутался.

и вот
 
Ну вот гугл говорит:

Или вот это:
Код:
<head>
 <title>Widgets, Inc</title>
  <link rel="alternate" hreflang="en-gb"
       href="https://en-gb.example.com/page.html" />
  <link rel="alternate" hreflang="en-us"
       href="https://en-us.example.com/page.html" />
  <link rel="alternate" hreflang="en"
       href="https://en.example.com/page.html" />
  <link rel="alternate" hreflang="de"
       href="https://de.example.com/page.html" />
 <link rel="alternate" hreflang="x-default"
       href="https://www.example.com/" />
</head>

Должно быть только на главной?
А в конкретной теме должно быть только указание языка страницы?
Блин я уже запутался.

и вот
Если у вас форум поддерживает мультиязычность при помощи поддоменов или других методов, то можно сделать, а силой мысли ссылка на тему с другим названием там не появится.
 
Если у вас форум поддерживает мультиязычность при помощи поддоменов или других методов, то можно сделать, а силой мысли ссылка на тему с другим названием там не появится.
У меня два узла.
В одном узле темы на русском языке. в другом узле темы на английском языке.
 
Этот код добавляет hreflang в английском форуме: (его id 20)
Код:
<xf:if is="{{ in_array($thread.Forum.Node.node_id, [20]) }}">
    <xf:head option="lang">
        <link rel="alternate" hreflang="en" href="{{ $xf.fullUri }}"/>
    </xf:head>
</xf:if>

Мне нужно теперь добавить код hreflang в узел на русском языке (его id 21)
Добавить ниже:
Код:
<xf:if is="{{ in_array($thread.Forum.Node.node_id, [21]) }}">

    <xf:head option="lang">

        <link rel="alternate" hreflang="en" href="{{ $xf.fullUri }}"/>

    </xf:head>

</xf:if>

верно?

в итоге в thread_view два таких кода?
 
Этот код добавляет hreflang в английском форуме: (его id 20)
Этот код добавляет hreflang в темы, созданные в разделе с ID 20.

Мне нужно теперь добавить код hreflang в узел на русском языке (его id 21)
Верно.
 
Последнее редактирование:
recruty , еще вопрос
А как hreflang для страниц сделать?

У меня есть например pages/about и pages/about_france

В таком случае думаю можно проставить обратную ссылку.
У каждой страницы, созданной через узлы, есть свой шаблон.

Пример кода для Франции (hreflang замените на свой, если я неправильно указал):
Код:
<xf:head option="lang">
    <link rel="alternate" hreflang="fr" href="{{ link('pages/about_france') }}"/>
</xf:head>

Код вставить где-нибудь в начале шаблона.
 
Последнее редактирование:
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу