Problem
Using Grav CMS (v1.5.8) I want to redirect the user to other pages. The page is a multilanguage setup and depending on the selected language, the route to the the base / start pages for the languages are simply:
www.example.com/
and
www.example.com/en
From a page, let's say error, I want to direct the user back to this start page. I realised this using the following code in the twig template:
<a href="{{ uri.base }}/{{ grav.language.getLanguage }}" class="btn">
which generates the correct url including the language string maintaining the current language.
Question
Is there any Grav API that handles generating / getting the root including the current language in a short way?
I figured that the redirect in a multi-language environment works if you use simply
page.find('<the page you want to direct to>').url
So in case of my question, redirecting to home would be
<a href="{{ page.find('home') }}" class="btn">
which resolves with the current language string.
Related
I'm trying to wrap my head around how I can go into the Netlify CMS and be able to edit the home page texts using Hugo. Days of research is leading me nowhere since all documents are about doing blog posts.
Right now I have my Netlify config.yml in the static/admin and an index.html file in the layouts folder. What do I need to do to be able to go into the Netlify dashboard and edit fields which will change texts on home page?
If I were to make the index.html as a markdown file in the content folder, how can I pull that data within the index.md to the index.html that lives in the layout folder?
If netlifycms is already in the site and that site is on netlify, then the next step is to add your account as a user to the site.
Open the site in the app.netlify.com/sites
Click on the Identity tab
Invite users
Accept invitation
Open up YOURDOMAIN.COM/admin page
Netlify will prompt for a login
I've had the same problem figuring out how to do netlifycms. Instructions are generally weak on where one does what. Sometimes creating an account/password is also problematic. Good luck!
Your index.html would need to be something like:
{{ define "main" }}
<article>
<h1>{{.Title}}</h1>
{{.Content}}
<!-- any other homepage html -->
</article>
{{ end }}
And then that will be populated with the content of content/_index.md in the same way as any other content page.
---
title: My homepage
date: 2020-04-24T10:48:46.000Z
---
User-editable homepage content, easily managed with Netlify CMS
Contents for the home page has to be in content/_index.md (or _index.en.md for multilingual).
If your netlify-cms config for pages collection does not match this (for example if you keep your pages in content/pages/*.md), then you need a special collection configured with file: content/_index.md.
I have a subdomain and a primary. The subdomain is a blog and is built on Wordpress, and the main site is on the Shopify platform. I set up some 301s from the blog to the primary domain and they work, but for some reason are adding an id parameter to the end of the urls.
I'm using the standard Redirect 301 /old /new in an htaccess file. I've never had this happen before when using this method, so I assume it's a Shopify thing. Has anyone ever experienced this, or know how to make it stop doing it?
Right now I have resolved the canonical issue using the follow Liquid code:
{% assign urlArray = canonical_url | split: '?' %}
<link rel="canonical" href="{{ urlArray | first }}">
I'd really like to remove it from the address bar as well if possible.
I have a dynamically part static and part dynamic url I wish to redirect to another page but keep part of the URL the same (domain).
My structure will be as follows:
www.domaina.com/query(folder)/?123,456,789
To redirect to
www.domainb.com/query(folder)/?123,456,789
But I wish to keep the URL in the address bar reading as domaina.com not domainb.com.
The sites are on different servers and htacces rules will differ from site to site (some may be static sites in the root and some maybe wordpress etc) and will sometimes be on different servers.
Thanks
Look into iFrames instead of doing this with htaccess code.
Edit|Update: Use iframes and not frameset. frameset is not supported in HTML5. See this w3schools tutorial page. Adding an iframe is very simple so keep everything very simple - http://www.w3schools.com/tags/tag_iframe.asp
<frameset rows="100%">
<frameset cols="100%">
<frame src="http://www.domain.com/page-i-want-to-display" frameborder="0" scrolling="yes">
</frameset>
</frameset>
I have a site (say site1.com) which 301-redirects to another page on a different site (say http://site2.com/some/dirty/url).
Typical code at site1.com:
<?php
header("HTTP/1.1 301"); header("refresh:0;url=http://site2.com/some/dirty/url");
?><html>
<head>
<title>
Site 1 - heading.
</title>
<meta name="description" content="some description" />
</head>
<body />
</html>
Typically, Search Engines never index site1.com, even when there are external links like:
Click Here
But this is considered as an external link to http://site2.com/some/dirty/url and thus http://site2.com/some/dirty/url is seo'd.
I some how want to get site1.com indexed (Just the title, meta description and URL) though http://site2.com/some/dirty/url getting indexed is not a problem. Is this really possible or is it just what I have to forget about?
The 301 redirect tells search engines, and any other user agent that respects HTTP status codes, that http://site.com no longer exists and has moved to a new location. This means they now consider the new location of http://site.com to be http://site2.com/some/dirty/url and to associate everything, including all links to http://site.com to be associated with http://site2.com/some/dirty/url. So basically http://site.com does not exist anymore and no matter how many links you point to it, it won't change anything since they now will be associated with http://site2.com/some/dirty/url. And that makes sense since a 301 HTTP status does indicate that a page has moved permanently. If that page hasn't moved permanently then you are using the wrong HTTP status code.
Yes,It can be indexed......But it requires a better on page work on the both of your sites
(http://site.com) and (http://site2.com/some/dirty/url) .............
For example I have recently worked on the same conditions the website url is "http://www.top-alliance.de" which redirects to "http://www.top-alliance.com" and these both sites are indexed by the search engine recently by 04 June 2012.This is happened because i have done a better onpage work for both pages...
So the conclusion is the both your sites will require better on page work so it will definitely indexed by the search engine.
Thanks & Regards
Nitin Bhatnagar
To easily create redirects in your WordPress, an alternative is a simple 301 redirect plugin. Once you've installed and activated the plugin, add a new menu in the Settings area of your dashboard.
There is really nothing to worry about with this plugin. The 301 Redirect Configuration window shows you two simple fields. One labeled as a request and the other as a destination. This is basically where the old permanent link structure and the new permanent link structure come from. You only need to add information after your domain name in these fields.
In the example above, the request field is the WordPress setting for the month and name Permilix, while the destination field is the WordPress setting for the post name Permalink structure. After you add these two fields, save your changes. It will ask any search engine traffic to come back to the old links.
We are creating a custom branded Master Page in SharePoint 2010. To make the page similar to a legacy page we have implemented an html based custom dropdown navigation menu we had in place directly on the Master Page (consisted of basic HTML elements ULs and LIs with A tags styled with a CSS class).
I assumed the links from the basic HTML on the page would be subject to Alternate Access Mappings currently in place, but it seems to not be the case. On a test page opened in 3 different URLs (http://sharepoint2010, http://sharepoint2010.mydomain.com, https://sharepoint2010.mydomain.com) the links from a WIKI page are modified as I expected, but the links from the Custom Navigation Menu (plain HTML on the Master Page) are not modified.
I can see where that would be useful... But is there a way that I can add links on the MasterPage in a way that SharePoint parses them first, making them subject to Alternate Access Mapping translation? I tried placing a link inside a SPLinkButton control, but it didn't achieve the desired behavior.
e.g.
<ul id="navmenu">
<li><SharePoint:SPLinkButton runat="server" NavigateUrl="http://sharepoint2010">sharepoint link</SharePoint:SPLinkButton></li>
<li>sharepoint2010</li>
<li>test</li>
</ul>
When I access the page via https://sharepoint2010.mydomain.com the links above are still http://sharepoint2010 rather than https://sharepoint2010.mydomain.com
Any thoughts?
Thanks,
Victor
EDIT (clarify):
I was planning on using relative links as a fallback. But for the purpose of what we are doing it would be more maintainable if we could keep the full links and use AAM.
I'm aware that standard relative links are a possibility. I was hoping to identify if there is a way to use AAM on Master Page content (or even on Content Retrieved from External Services down the road) by providing a specific link syntax, or control framework.
There is no need to re-insert the host name if your links are on the same domain and you're not using managed paths. Keeping your links relative will ensure that any bindings in IIS and AAM setup in SharePoint will work without any additional work.
Otherwise, I would heavily suggest to use the available ~sitecollection and ~site SPUrl token to retrieve the current site collection url or current web url. You need to wrap it in anything running server side as the expression will be handled ... server side.
eg:
<asp:Literal runat="server" Text="<% $SPUrl:~site/press-releases/ %>"/>
Hope it helped
When you use the NavigateUrl= attribute of the SPLinkButton, SharePoint renders a simple anchor with href= instead of regular PostBack JavaScript code. Alternate access mapping do not play a role here.
If its simply relative links you want, then leave out the dns entry altogether (ie the bit of the url you are switching with your AAM) and begin the url with a forward slash to make it relative. If this doesn't meet your needs, the way Sharepoint does it is with a relative url token. Have a look in v4.master for the tilda character followed by 'site' or 'sitecollection' which refers to the current web and site collection respectively. Copy this method. For more details, look at this link: http://msdn.microsoft.com/en-us/library/ms473643.aspx