Skip to content

Commit 6703f65

Browse files
Added cannonical URL to topics, blog posts & newsitems
1 parent 941b921 commit 6703f65

File tree

3 files changed

+192
-167
lines changed

3 files changed

+192
-167
lines changed
Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
@model BlogPostModel
22
@using SmartStore.Web.Models.Blogs;
3+
@using SmartStore.Core.Domain.Seo;
34
@{
45
Layout = "_Layout";
56

67
Html.AddTitleParts(Model.MetaTitle.HasValue() ? Model.MetaTitle : Model.Title);
78
Html.AddMetaDescriptionParts(Model.MetaDescription);
89
Html.AddMetaKeywordParts(Model.MetaKeywords);
10+
11+
var blogPostUrl = Url.RouteUrl("BlogPost", new { SeName = Model.SeName }, this.Request.Url.Scheme);
12+
var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
13+
if (canonicalUrlsEnabled)
14+
{
15+
Html.AddCanonicalUrlParts(blogPostUrl);
16+
}
917
}
1018

1119
@{ Html.RenderAction("MetaPropertiesBlog", "Common", new { blogPost = Model }); }
1220

1321
@section right {
1422
@{
1523
Html.RenderAction("BlogMonths", "Blog");
16-
Html.RenderWidget("blog_right_months_after");
24+
Html.RenderWidget("blog_right_months_after");
1725
Html.RenderAction("BlogTags", "Blog");
18-
Html.RenderWidget("blog_right_bottom");
26+
Html.RenderWidget("blog_right_bottom");
1927
}
2028
}
2129

2230
<article class="page blogpost-page" itemprop="mainEntity" itemscope itemtype="http://schema.org/BlogPosting">
2331

2432
@if (Model.DisplayAdminLink)
25-
{
26-
<a class="btn btn-secondary btn-flat btn-admin-edit" href="@Url.Action("Edit", "Blog", new { id = Model.Id, area = "admin" })" target="admin-blogpost" rel="nofollow">
27-
<i class="fa fa-cog"></i>
28-
<span>@T("Common.Cms.EditBlogpost")</span>
29-
</a>
30-
}
33+
{
34+
<a class="btn btn-secondary btn-flat btn-admin-edit" href="@Url.Action("Edit", "Blog", new { id = Model.Id, area = "admin" })" target="admin-blogpost" rel="nofollow">
35+
<i class="fa fa-cog"></i>
36+
<span>@T("Common.Cms.EditBlogpost")</span>
37+
</a>
38+
}
3139

3240
@if (Model.PictureModel.FullSizeImageUrl.HasValue())
3341
{
@@ -48,11 +56,11 @@
4856
<meta itemprop="url" content="@Request.Url.AbsoluteUri" />
4957

5058
<div class="page-title mb-4 mt-3">
51-
<h1 class="fs-h2" itemprop="headline">@Model.Title</h1>
59+
<h1 class="fs-h2" itemprop="headline">@Model.Title</h1>
5260
</div>
5361

5462
<div class="blogpost-body">
55-
63+
5664
@{ Html.RenderWidget("blogpost_page_before_body"); }
5765

5866
<div class="blogpost-content long-text html-editor-content" itemprop="articleBody">
@@ -73,62 +81,62 @@
7381
<meta itemprop="articleSection" content="@keywords" />
7482
<meta itemprop="keywords" content="@keywords" />
7583

76-
}
77-
78-
@{ Html.RenderWidget("blogpost_page_before_comments"); }
79-
80-
@if (Model.Comments.AllowComments)
81-
{
82-
<div class="row">
83-
<div class="col-12">
84-
<div class="block blog-comment-form mt-5">
85-
@using (Html.BeginForm())
86-
{
87-
<fieldset class="blog-comment-form content-group mt-5">
88-
<legend><span>@T("Blog.Comments.LeaveYourComment")</span></legend>
89-
90-
@if (ViewContext.ViewData.ModelState.ContainsKey(""))
91-
{
92-
@Html.ValidationSummary(true)
93-
}
94-
95-
@if (this.EnableHoneypotProtection)
96-
{
97-
<div class="d-none">
98-
@Html.HoneypotField()
99-
</div>
100-
}
101-
102-
<div class="form-group">
103-
@Html.TextAreaFor(model => model.AddNewComment.CommentText, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentText), rows = "6" })
104-
@Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
105-
</div>
106-
107-
@{ Html.RenderWidget("gdpr_consent"); }
108-
109-
@if (Model.AddNewComment.DisplayCaptcha)
110-
{
111-
<div class="form-group">
112-
<div class="captcha-box">
113-
@Html.Raw(Html.GenerateCaptcha())
114-
</div>
115-
</div>
116-
}
117-
118-
<div class="form-group">
119-
<button type="submit" name="add-comment" value="add-comment" class="btn btn-primary btn-lg">
120-
@T("Blog.Comments.SubmitButton")
121-
</button>
122-
</div>
123-
</fieldset>
124-
}
125-
</div>
126-
127-
@{ Html.RenderPartial("Comment.List", Model.Comments); }
128-
</div>
129-
</div>
130-
}
131-
132-
@{ Html.RenderWidget("blogpost_page_after_comments"); }
84+
}
85+
86+
@{ Html.RenderWidget("blogpost_page_before_comments"); }
87+
88+
@if (Model.Comments.AllowComments)
89+
{
90+
<div class="row">
91+
<div class="col-12">
92+
<div class="block blog-comment-form mt-5">
93+
@using (Html.BeginForm())
94+
{
95+
<fieldset class="blog-comment-form content-group mt-5">
96+
<legend><span>@T("Blog.Comments.LeaveYourComment")</span></legend>
97+
98+
@if (ViewContext.ViewData.ModelState.ContainsKey(""))
99+
{
100+
@Html.ValidationSummary(true)
101+
}
102+
103+
@if (this.EnableHoneypotProtection)
104+
{
105+
<div class="d-none">
106+
@Html.HoneypotField()
107+
</div>
108+
}
109+
110+
<div class="form-group">
111+
@Html.TextAreaFor(model => model.AddNewComment.CommentText, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentText), rows = "6" })
112+
@Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
113+
</div>
114+
115+
@{ Html.RenderWidget("gdpr_consent"); }
116+
117+
@if (Model.AddNewComment.DisplayCaptcha)
118+
{
119+
<div class="form-group">
120+
<div class="captcha-box">
121+
@Html.Raw(Html.GenerateCaptcha())
122+
</div>
123+
</div>
124+
}
125+
126+
<div class="form-group">
127+
<button type="submit" name="add-comment" value="add-comment" class="btn btn-primary btn-lg">
128+
@T("Blog.Comments.SubmitButton")
129+
</button>
130+
</div>
131+
</fieldset>
132+
}
133+
</div>
134+
135+
@{ Html.RenderPartial("Comment.List", Model.Comments); }
136+
</div>
137+
</div>
138+
}
139+
140+
@{ Html.RenderWidget("blogpost_page_after_comments"); }
133141
</div>
134142
</article>

src/Presentation/SmartStore.Web/Views/News/NewsItem.cshtml

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@model NewsItemModel
22
@using SmartStore.Web.Models.News;
3+
@using SmartStore.Core.Domain.Seo;
34

45
@{
56
Layout = "_Layout";
@@ -8,19 +9,26 @@
89
Html.AddMetaDescriptionParts(Model.MetaDescription);
910
Html.AddMetaKeywordParts(Model.MetaKeywords);
1011

11-
var imageUrl = Url.Media(Model.PictureModel.File, 0, null, false);
12+
var newsItemUrl = Url.RouteUrl("NewsItem", new { SeName = Model.SeName }, this.Request.Url.Scheme);
13+
var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
14+
if (canonicalUrlsEnabled)
15+
{
16+
Html.AddCanonicalUrlParts(newsItemUrl);
17+
}
18+
19+
var imageUrl = Url.Media(Model.PictureModel.File, 0, null, false);
1220
}
1321

1422
@{ Html.RenderAction("MetaPropertiesNews", "Common", new { newsItem = Model }); }
1523

1624
<article class="page news-item-page" itemscope itemtype="http://schema.org/NewsArticle">
1725
@if (Model.DisplayAdminLink)
18-
{
19-
<a class="btn btn-secondary btn-flat btn-admin-edit" href="@Url.Action("Edit", "News", new { id = Model.Id, area = "admin" })" target="admin-newsitem" rel="nofollow">
20-
<i class="fa fa-cog"></i>
21-
<span>@T("Common.Cms.EditNewsItem")</span>
22-
</a>
23-
}
26+
{
27+
<a class="btn btn-secondary btn-flat btn-admin-edit" href="@Url.Action("Edit", "News", new { id = Model.Id, area = "admin" })" target="admin-newsitem" rel="nofollow">
28+
<i class="fa fa-cog"></i>
29+
<span>@T("Common.Cms.EditNewsItem")</span>
30+
</a>
31+
}
2432

2533
@if (imageUrl.HasValue())
2634
{
@@ -60,52 +68,52 @@
6068

6169
@if (Model.Comments.AllowComments)
6270
{
63-
<div class="row">
64-
<div class="col-12">
65-
<div class="block news-comment-form mt-5">
66-
@using (Html.BeginForm())
67-
{
68-
<fieldset class="news-comment-form content-group mt-5">
69-
<legend><span>@T("News.Comments.LeaveYourComment")</span></legend>
70-
71-
@if (ViewContext.ViewData.ModelState.ContainsKey(""))
72-
{
73-
@Html.ValidationSummary(true)
74-
}
75-
76-
<div class="form-group">
77-
@Html.TextBoxFor(model => model.AddNewComment.CommentTitle, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentTitle) })
78-
@Html.ValidationMessageFor(model => model.AddNewComment.CommentTitle)
79-
</div>
80-
81-
<div class="form-group">
82-
@Html.TextAreaFor(model => model.AddNewComment.CommentText, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentText), rows = "6" })
83-
@Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
84-
</div>
85-
86-
@{ Html.RenderWidget("gdpr_consent"); }
87-
88-
@if (Model.AddNewComment.DisplayCaptcha)
89-
{
90-
<div class="form-group">
91-
<div class="captcha-box">
92-
@Html.Raw(Html.GenerateCaptcha())
93-
</div>
94-
</div>
95-
}
96-
97-
<div class="form-group">
98-
<button type="submit" name="add-comment" value="add-comment" class="btn btn-primary btn-lg">
99-
@T("News.Comments.SubmitButton")
100-
</button>
101-
</div>
102-
</fieldset>
103-
}
104-
</div>
105-
106-
@{ Html.RenderPartial("Comment.List", Model.Comments); }
107-
</div>
108-
</div>
71+
<div class="row">
72+
<div class="col-12">
73+
<div class="block news-comment-form mt-5">
74+
@using (Html.BeginForm())
75+
{
76+
<fieldset class="news-comment-form content-group mt-5">
77+
<legend><span>@T("News.Comments.LeaveYourComment")</span></legend>
78+
79+
@if (ViewContext.ViewData.ModelState.ContainsKey(""))
80+
{
81+
@Html.ValidationSummary(true)
82+
}
83+
84+
<div class="form-group">
85+
@Html.TextBoxFor(model => model.AddNewComment.CommentTitle, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentTitle) })
86+
@Html.ValidationMessageFor(model => model.AddNewComment.CommentTitle)
87+
</div>
88+
89+
<div class="form-group">
90+
@Html.TextAreaFor(model => model.AddNewComment.CommentText, new { @class = "form-control form-control-lg", placeholder = Html.DisplayNameFor(m => m.AddNewComment.CommentText), rows = "6" })
91+
@Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
92+
</div>
93+
94+
@{ Html.RenderWidget("gdpr_consent"); }
95+
96+
@if (Model.AddNewComment.DisplayCaptcha)
97+
{
98+
<div class="form-group">
99+
<div class="captcha-box">
100+
@Html.Raw(Html.GenerateCaptcha())
101+
</div>
102+
</div>
103+
}
104+
105+
<div class="form-group">
106+
<button type="submit" name="add-comment" value="add-comment" class="btn btn-primary btn-lg">
107+
@T("News.Comments.SubmitButton")
108+
</button>
109+
</div>
110+
</fieldset>
111+
}
112+
</div>
113+
114+
@{ Html.RenderPartial("Comment.List", Model.Comments); }
115+
</div>
116+
</div>
109117
}
110118

111119
@{ Html.RenderWidget("newsitem_page_after_comments"); }

0 commit comments

Comments
 (0)